-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsurface_plot_example_2.f90
60 lines (48 loc) · 1.51 KB
/
surface_plot_example_2.f90
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
50
51
52
53
54
55
56
57
58
59
60
program example
use, intrinsic :: iso_fortran_env
use fplot_core
implicit none
! Parameters
integer(int32), parameter :: m = 50
integer(int32), parameter :: n = 50
real(real64), parameter :: xMax = 5.0d0
real(real64), parameter :: xMin = -5.0d0
real(real64), parameter :: yMax = 5.0d0
real(real64), parameter :: yMin = -5.0d0
! Local Variables
real(real64), dimension(n) :: xdata
real(real64), dimension(m) :: ydata
real(real64), dimension(:,:), pointer :: x, y
real(real64), dimension(m, n, 2), target :: xy
real(real64), dimension(m, n) :: z
type(surface_plot) :: plt
type(surface_plot_data) :: d1
type(rainbow_colormap) :: map
class(plot_axis), pointer :: xAxis, yAxis, zAxis
! Define the data
xdata = linspace(xMin, xMax, n)
ydata = linspace(yMin, yMax, m)
xy = meshgrid(xdata, ydata)
x => xy(:,:,1)
y => xy(:,:,2)
! Define the function to plot
z = sin(sqrt(x**2 + y**2))
! Define colormap settings
call map%set_show_tics(.false.)
! Create the plot
call plt%initialize()
call plt%set_colormap(map)
! Define titles
call plt%set_title("Example Plot")
xAxis => plt%get_x_axis()
call xAxis%set_title("X Axis")
yAxis => plt%get_y_axis()
call yAxis%set_title("Y Axis")
zAxis => plt%get_z_axis()
call zAxis%set_title("Z Axis")
! Define the data set
call d1%define_data(x, y, z)
call plt%push(d1)
! Let GNUPLOT draw the plot
call plt%draw()
end program