-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcustom_colormap_example.f90
More file actions
49 lines (40 loc) · 1.23 KB
/
Copy pathcustom_colormap_example.f90
File metadata and controls
49 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
program example
use fplot_core
use iso_fortran_env
use forcolormap
implicit none
! Parameters
integer(int32), parameter :: m = 50
integer(int32), parameter :: n = 50
! Local Variables
real(real64), dimension(m, n, 2), target :: xy
real(real64), pointer, dimension(:,:) :: x, y
real(real64), dimension(m, n) :: z
type(surface_plot) :: plt
type(custom_colormap) :: map
type(cmap) :: colors
! Set up the colormap
call colors%set("glasgow", -8.0d0, 8.0d0)
call map%set_colormap(colors)
! Define the data
xy = meshgrid(linspace(-5.0d0, 5.0d0, n), linspace(-5.0d0, 5.0d0, m))
x => xy(:,:,1)
y => xy(:,:,2)
! Initialize the plot
call plt%initialize()
call plt%set_colormap(map)
call plt%set_x_axis_title("X Axis")
call plt%set_y_axis_title("Y Axis")
call plt%set_z_axis_title("Z Axis")
call plt%set_title("Custom Colormap")
! Establish lighting
call plt%set_use_lighting(.true.)
! Set the orientation of the plot
call plt%set_elevation(20.0d0)
call plt%set_azimuth(30.0d0)
! Define the function to plot
z = sqrt(x**2 + y**2) * sin(x**2 + y**2)
call plt%push(x, y, z)
! Draw the plot
call plt%draw()
end program