-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgeneric_2d_plot.f90
62 lines (49 loc) · 1.58 KB
/
generic_2d_plot.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
61
62
program example
use, intrinsic :: iso_fortran_env
use fplot_core
implicit none
! Parameters
integer(int32), parameter :: n = 1000
! Local Variables
real(real64), dimension(n) :: x, y1, y2
type(plot_2d) :: plt
type(plot_data_2d) :: d1, d2
class(plot_axis), pointer :: xAxis, yAxis
type(legend), pointer :: leg
! Initialize the plot object
call plt%initialize()
! Define titles
call plt%set_title("Example Plot")
call plt%set_font_size(14)
xAxis => plt%get_x_axis()
call xAxis%set_title("X Axis")
yAxis => plt%get_y_axis()
call yAxis%set_title("Y Axis")
! Establish legend properties
leg => plt%get_legend()
call leg%set_is_visible(.true.)
call leg%set_draw_inside_axes(.false.)
call leg%set_horizontal_position(LEGEND_CENTER)
call leg%set_vertical_position(LEGEND_BOTTOM)
call leg%set_draw_border(.false.)
! Define the data, and then add it to the plot
x = linspace(0.0d0, 10.0d0, n)
y1 = sin(5.0d0 * x)
y2 = 2.0d0 * cos(2.0d0 * x)
call d1%define_data(x, y1)
call d2%define_data(x, y2)
! Define properties for each data set
call d1%set_name("Data Set 1")
call d1%set_draw_markers(.true.)
call d1%set_marker_frequency(10)
call d1%set_marker_style(MARKER_EMPTY_CIRCLE)
call d1%set_marker_scaling(2.0)
call d2%set_name("Data Set 2")
call d2%set_line_style(LINE_DASHED)
call d2%set_line_width(2.0)
! Add the data sets to the plot
call plt%push(d1)
call plt%push(d2)
! Let GNUPLOT draw the plot
call plt%draw()
end program