Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d9ded3f

Browse files
authoredMar 27, 2024
Merge pull request #49 from jacobwilliams/develop
updates
2 parents a362b18 + a8ad996 commit d9ded3f

File tree

4 files changed

+324
-250
lines changed

4 files changed

+324
-250
lines changed
 

‎.gitignore

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
bin/
2-
lib/
3-
doc/
4-
build/
5-
__pycache__
6-
7-
# Compiled Object files
8-
*.slo
9-
*.lo
10-
*.o
11-
*.obj
12-
13-
# Precompiled Headers
14-
*.gch
15-
*.pch
16-
17-
# Compiled Dynamic libraries
18-
*.so
19-
*.dylib
20-
*.dll
21-
22-
# Fortran module files
23-
*.mod
24-
25-
# Compiled Static libraries
26-
*.lai
27-
*.la
28-
*.a
29-
*.lib
30-
31-
# Executables
32-
*.exe
33-
*.out
34-
*.app
35-
36-
# Generated Test Files
37-
test/*.png
38-
test/*.py
39-
40-
# misc
41-
.DS_Store
1+
bin/
2+
lib/
3+
doc/
4+
build/
5+
__pycache__
6+
7+
# Compiled Object files
8+
*.slo
9+
*.lo
10+
*.o
11+
*.obj
12+
13+
# Precompiled Headers
14+
*.gch
15+
*.pch
16+
17+
# Compiled Dynamic libraries
18+
*.so
19+
*.dylib
20+
*.dll
21+
22+
# Fortran module files
23+
*.mod
24+
25+
# Compiled Static libraries
26+
*.lai
27+
*.la
28+
*.a
29+
*.lib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
36+
# Generated Test Files
37+
test/*.png
38+
test/*.py
39+
40+
# misc
41+
.DS_Store
42+
/env

‎src/pyplot_module.F90

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ module pyplot_module
7171
logical :: tight_layout = .false. !! tight layout option
7272
logical :: usetex = .false. !! enable LaTeX
7373

74+
character(len=:),allocatable :: xaxis_date_fmt !! date format for the x-axis. Example: `"%m/%d/%y %H:%M:%S"`
75+
character(len=:),allocatable :: yaxis_date_fmt !! date format for the y-axis. Example: `"%m/%d/%y %H:%M:%S"`
76+
7477
character(len=:),allocatable :: real_fmt !! real number formatting
7578

7679
contains
@@ -162,7 +165,7 @@ end subroutine add_str
162165
subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy, figsize, &
163166
font_size, axes_labelsize, xtick_labelsize, ytick_labelsize, ztick_labelsize, &
164167
legend_fontsize, mplot3d, axis_equal, polar, real_fmt, use_oo_api, axisbelow,&
165-
tight_layout, raw_strings, usetex)
168+
tight_layout, raw_strings, usetex, xaxis_date_fmt, yaxis_date_fmt)
166169

167170
class(pyplot), intent(inout) :: me !! pyplot handler
168171
logical, intent(in), optional :: grid !! activate grid drawing
@@ -189,6 +192,8 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
189192
logical, intent(in), optional :: raw_strings !! if True, all strings sent to Python are treated as
190193
!! raw strings (e.g., r'str'). Default is False.
191194
logical, intent(in), optional :: usetex !! if True, enable LaTeX. (default if false)
195+
character(len=*), intent(in), optional :: xaxis_date_fmt !! if present, used to set the date format for the x-axis
196+
character(len=*), intent(in), optional :: yaxis_date_fmt !! if present, used to set the date format for the y-axis
192197

193198
character(len=max_int_len) :: width_str !! figure width dummy string
194199
character(len=max_int_len) :: height_str !! figure height dummy string
@@ -257,6 +262,16 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
257262
else
258263
me%usetex = .false.
259264
end if
265+
if (present(xaxis_date_fmt)) then
266+
me%xaxis_date_fmt = xaxis_date_fmt
267+
else
268+
if (allocated(me%xaxis_date_fmt)) deallocate(me%xaxis_date_fmt)
269+
end if
270+
if (present(yaxis_date_fmt)) then
271+
me%yaxis_date_fmt = yaxis_date_fmt
272+
else
273+
if (allocated(me%yaxis_date_fmt)) deallocate(me%yaxis_date_fmt)
274+
end if
260275

261276
call optional_int_to_string(font_size, font_size_str, default_font_size_str)
262277
call optional_int_to_string(axes_labelsize, axes_labelsize_str, default_font_size_str)
@@ -1401,11 +1416,11 @@ subroutine execute(me, pyfile, istat, python)
14011416
write(error_unit,'(A)') 'Error closing file: '//trim(file)
14021417
else
14031418

1404-
if (present(python)) then
1419+
if (present(python)) then
14051420
python_ = trim(python)
1406-
else
1421+
else
14071422
python_ = python_exe
1408-
end if
1423+
end if
14091424

14101425
!run the file using python:
14111426
if (index(file,' ')>0) then
@@ -1477,6 +1492,14 @@ subroutine finish_ops(me)
14771492
end if
14781493
call me%add_str('')
14791494
end if
1495+
if (allocated(me%xaxis_date_fmt) .or. allocated(me%yaxis_date_fmt)) then
1496+
call me%add_str('from matplotlib.dates import DateFormatter')
1497+
if (allocated(me%xaxis_date_fmt)) &
1498+
call me%add_str('ax.xaxis.set_major_formatter(DateFormatter("'//trim(me%xaxis_date_fmt)//'"))')
1499+
if (allocated(me%yaxis_date_fmt)) &
1500+
call me%add_str('ax.yaxis.set_major_formatter(DateFormatter("'//trim(me%yaxis_date_fmt)//'"))')
1501+
call me%add_str('')
1502+
end if
14801503
if (me%tight_layout) then
14811504
call me%add_str('fig.tight_layout()')
14821505
call me%add_str('')

‎test/date_test.f90

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
!*****************************************************************************************
2+
!>
3+
! Unit test for [[pyplot_module]]. Using the `xaxis_date_fmt` option for x-axis dates.
4+
5+
program date_test
6+
7+
use pyplot_module, only : pyplot, wp => pyplot_wp
8+
9+
implicit none
10+
11+
integer,parameter :: n = 100
12+
13+
real(wp), dimension(:),allocatable :: x !! x values
14+
real(wp), dimension(:),allocatable :: y !! y values
15+
real(wp), dimension(:),allocatable :: sx !! sin(x) values
16+
real(wp), dimension(:),allocatable :: cx !! cos(x) values
17+
real(wp), dimension(:),allocatable :: tx !! sin(x)*cos(x) values
18+
type(pyplot) :: plt !! pytplot handler
19+
integer :: i !! counter
20+
integer :: istat !! status code
21+
22+
character(len=*), parameter :: testdir = "test/"
23+
character(len=*), parameter :: xaxis_date_fmt = '%m/%d/%y %H:%M:%S'
24+
character(len=*), parameter :: yaxis_date_fmt = '%H:%M:%S'
25+
26+
! size arrays:
27+
allocate(x(n))
28+
allocate(sx(n))
29+
allocate(cx(n))
30+
allocate(tx(n))
31+
32+
!generate some data:
33+
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
34+
sx = 10*sin(x)
35+
cx = cos(x)
36+
tx = sx * cx
37+
38+
!2d line plot:
39+
call plt%initialize(grid=.true.,xlabel='Calendar date',figsize=[20,10],&
40+
title='date test',legend=.true.,axis_equal=.true.,&
41+
tight_layout=.true., &
42+
xaxis_date_fmt=xaxis_date_fmt, yaxis_date_fmt=yaxis_date_fmt)
43+
call plt%add_plot(x,sx,label='$\sin (x)$',linestyle='b-o',markersize=5,linewidth=2,istat=istat)
44+
call plt%add_plot(x,cx,label='$\cos (x)$',linestyle='r-o',markersize=5,linewidth=2,istat=istat)
45+
call plt%add_plot(x,tx,label='$\sin (x) \cos (x)$',linestyle='g-o',markersize=2,linewidth=1,istat=istat)
46+
call plt%savefig(testdir//'datetest.png', pyfile=testdir//'datetest.py',&
47+
istat=istat)
48+
49+
end program date_test
50+
!*****************************************************************************************

‎test/test.f90

Lines changed: 205 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -1,205 +1,205 @@
1-
!*****************************************************************************************
2-
!> author: Jacob Williams
3-
! date: 4/14/2015
4-
! license: BSD
5-
!
6-
! Unit test for [[pyplot_module]].
7-
8-
program test
9-
10-
use pyplot_module, only : pyplot, wp => pyplot_wp
11-
12-
implicit none
13-
14-
integer,parameter :: n = 100
15-
16-
real(wp), dimension(:),allocatable :: x !! x values
17-
real(wp), dimension(:),allocatable :: y !! y values
18-
real(wp), dimension(:),allocatable :: xerr !! error values
19-
real(wp), dimension(:),allocatable :: yerr !! error values for bar chart
20-
real(wp), dimension(:),allocatable :: sx !! sin(x) values
21-
real(wp), dimension(:),allocatable :: cx !! cos(x) values
22-
real(wp), dimension(:),allocatable :: zx !!
23-
real(wp), dimension(:),allocatable :: tx !! sin(x)*cos(x) values
24-
real(wp), dimension(:,:),allocatable :: z !! z matrix for contour plot
25-
real(wp), dimension(:,:),allocatable :: mat !! image values
26-
type(pyplot) :: plt !! pytplot handler
27-
integer :: i !! counter
28-
integer :: j !! counter
29-
real(wp) :: r2 !! temp variable
30-
integer :: istat !! status code
31-
32-
real(wp),parameter :: pi = acos(-1.0_wp)
33-
real(wp),parameter :: deg2rad = pi/180.0_wp
34-
35-
character(len=*), parameter :: testdir = "test/"
36-
37-
! size arrays:
38-
allocate(x(n))
39-
allocate(y(n))
40-
allocate(yerr(n))
41-
allocate(sx(n))
42-
allocate(cx(n))
43-
allocate(zx(n))
44-
allocate(tx(n))
45-
allocate(z(n,n))
46-
allocate(mat(n,n))
47-
48-
!generate some data:
49-
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
50-
sx = sin(x)
51-
cx = cos(x)
52-
tx = sx * cx
53-
zx = 0.0_wp
54-
yerr = abs(sx*.25_wp)
55-
56-
do i=1,n
57-
do j=1,n
58-
mat(i,j) = sin(real(i,wp)*real(j,wp))
59-
end do
60-
end do
61-
62-
!2d line plot:
63-
call plt%initialize(grid=.true.,xlabel='angle (rad)',figsize=[20,10],&
64-
title='plot test',legend=.true.,axis_equal=.true.,&
65-
tight_layout=.true.)
66-
call plt%add_plot(x,sx,label='$\sin (x)$',linestyle='b-o',markersize=5,linewidth=2,istat=istat)
67-
call plt%add_plot(x,cx,label='$\cos (x)$',linestyle='r-o',markersize=5,linewidth=2,istat=istat)
68-
call plt%add_plot(x,tx,label='$\sin (x) \cos (x)$',linestyle='g-o',markersize=2,linewidth=1,istat=istat)
69-
call plt%savefig(testdir//'plottest.png', pyfile=testdir//'plottest.py',&
70-
istat=istat)
71-
72-
!bar chart:
73-
tx = 0.1_wp !for bar width
74-
call plt%initialize(grid=.true.,xlabel='angle (rad)',&
75-
title='bar test',legend=.true.,figsize=[20,10],&
76-
font_size = 20,&
77-
axes_labelsize = 20,&
78-
xtick_labelsize = 20,&
79-
ytick_labelsize = 20,&
80-
legend_fontsize = 20, raw_strings=.true. )
81-
call plt%add_bar(x=x,height=sx,width=tx,label='$\sin (x)$',&
82-
color='r',yerr=yerr,xlim=[0.0_wp, 20.0_wp],align='center',istat=istat)
83-
call plt%savefig(testdir//'bartest.png', pyfile=testdir//'bartest.py',&
84-
istat=istat)
85-
86-
!contour plot:
87-
x = [(real(i,wp), i=0,n-1)]/100.0_wp
88-
y = [(real(i,wp), i=0,n-1)]/100.0_wp
89-
do i=1,n
90-
do j=1,n
91-
r2 = x(i)**2 + y(j)**2
92-
z(i,j) = sin(x(i))*cos(y(j))*sin(r2)/(1.0_wp+log(r2+1.0_wp))
93-
end do
94-
end do
95-
call plt%initialize(grid=.true.,xlabel='x angle (rad)',&
96-
ylabel='y angle (rad)',figsize=[10,10],&
97-
title='Contour plot test', real_fmt='*',&
98-
axisbelow=.false.)
99-
call plt%add_contour(x, y, z, linestyle='-', &
100-
filled=.true., cmap='bone', colorbar=.true.,&
101-
istat=istat)
102-
call plt%savefig(testdir//'contour.png',pyfile=testdir//'contour.py',istat=istat)
103-
104-
!image plot:
105-
call plt%initialize(grid=.true.,xlabel='x',ylabel='y',figsize=[20,20],&
106-
title='imshow test',&
107-
real_fmt='(F9.3)')
108-
call plt%add_imshow(mat,xlim=[0.0_wp, 100.0_wp],ylim=[0.0_wp, 100.0_wp],istat=istat)
109-
call plt%savefig(testdir//'imshow.png', pyfile=testdir//'imshow.py',&
110-
istat=istat)
111-
112-
!wireframe plot:
113-
call plt%initialize(grid=.true.,xlabel='x angle (rad)',&
114-
ylabel='y angle (rad)',figsize=[10,10],&
115-
title='Wireframe plot test', real_fmt='*',&
116-
axisbelow=.false.,mplot3d=.true.,use_numpy=.true.)
117-
call plt%plot_wireframe(x, y, z, label='', linestyle='-', &
118-
cmap='bone', colorbar=.true.,&
119-
istat=istat)
120-
call plt%savefig(testdir//'wireframe.png', pyfile=testdir//'wireframe.py',&
121-
istat=istat)
122-
123-
!histogram chart:
124-
x = [0.194,0.501,-1.241,1.425,-2.217,-0.342,-0.979,0.909,0.994,0.101, &
125-
-0.131,-0.627,0.463,1.404,0.036,-2.000,0.109,1.250,-1.035,-1.115, &
126-
0.935,0.496,1.100,0.770,-1.307,-0.693,-0.072,-1.331,-0.701, &
127-
-0.494,0.666,-0.313,-0.430,-0.654,1.638,-0.334,-0.418,0.550,-0.034, &
128-
0.473,0.704,0.801,-0.157,0.055,-0.057,-1.049,-1.022,0.495,0.756, &
129-
0.149,0.543,-0.813,-0.171,-0.994,-1.532,0.502,1.324,-0.593,-0.467, &
130-
0.372,-0.904,1.255,0.931,-0.779,1.529,-0.036,0.783,0.292,-0.792, &
131-
-0.223,-0.325,0.225,-0.492,-0.941,0.065,1.300,-1.241,-1.124,-0.499, &
132-
1.233,-0.845,-0.948,-1.060,1.103,-1.154,-0.594,0.335,-1.423,0.571, &
133-
-0.903,1.129,-0.372,-1.043,-1.327,0.147,1.056,1.068,-0.699,0.988,-0.630]
134-
135-
call plt%initialize(grid=.true.,xlabel='x',&
136-
title='hist test',&
137-
legend=.true.,figsize=[20,10],&
138-
font_size = 20,&
139-
axes_labelsize = 20,&
140-
xtick_labelsize = 20,&
141-
ytick_labelsize = 20,&
142-
legend_fontsize = 20 )
143-
144-
call plt%add_hist(x=x, label='x',istat=istat)
145-
call plt%savefig(testdir//'histtest1.png', pyfile=testdir//'histtest1.py',&
146-
istat=istat)
147-
148-
call plt%initialize(grid=.true.,xlabel='x',&
149-
title='cumulative hist test',&
150-
legend=.true.,figsize=[20,10],&
151-
font_size = 20,&
152-
axes_labelsize = 20,&
153-
xtick_labelsize = 20,&
154-
ytick_labelsize = 20,&
155-
legend_fontsize = 20 )
156-
157-
call plt%add_hist(x=x, label='x', bins=8, cumulative=.true.,istat=istat)
158-
call plt%savefig(testdir//'histtest2.png', &
159-
pyfile=testdir//'histtest2.py', &
160-
dpi='200', &
161-
transparent=.true.,istat=istat)
162-
163-
!3D plot:
164-
call plt%initialize(grid=.true.,&
165-
xlabel='x (km)',ylabel='y (km)',zlabel='z (km)',&
166-
title='Orbit',&
167-
axis_equal=.true.,&
168-
mplot3d=.true.,&
169-
figsize=[20,10] )
170-
171-
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
172-
sx = 7000.0_wp * cos(x * deg2rad)
173-
cx = 7000.0_wp * sin(x * deg2rad)
174-
zx = 0.0_wp
175-
call plt%add_3d_plot(sx,cx,zx,&
176-
label='orbit',linestyle='r-',&
177-
linewidth=2,istat=istat)
178-
call plt%add_sphere(6378.0_wp,0.0_wp,0.0_wp,0.0_wp,&
179-
color='Blue',n_facets=500,&
180-
antialiased=.true.,istat=istat)
181-
call plt%savefig(testdir//'orbit.png', &
182-
pyfile=testdir//'orbit.py', &
183-
dpi='200', &
184-
transparent=.true.,istat=istat)
185-
186-
! Errorbar plot:
187-
call plt%initialize(grid=.true.,&
188-
xlabel='x',ylabel='y',&
189-
title='Errorbar Plot Example',&
190-
figsize=[20,10] )
191-
192-
x = [(real(i,wp), i=0, 360, 10)]
193-
y = 10.0_wp * cos(x * deg2rad)
194-
xerr = sin(x * deg2rad) * 5.0_wp
195-
yerr = sin(y * deg2rad) * 10.0_wp
196-
197-
call plt%add_errorbar(x, y, label='y', linestyle='.', &
198-
xerr=xerr, yerr=yerr, istat=istat)
199-
call plt%savefig(testdir//'errorbar.png', &
200-
pyfile=testdir//'errorbar.py', &
201-
dpi='200', &
202-
transparent=.true.,istat=istat, python='python')
203-
204-
end program test
205-
!*****************************************************************************************
1+
!*****************************************************************************************
2+
!> author: Jacob Williams
3+
! date: 4/14/2015
4+
! license: BSD
5+
!
6+
! Unit test for [[pyplot_module]].
7+
8+
program test
9+
10+
use pyplot_module, only : pyplot, wp => pyplot_wp
11+
12+
implicit none
13+
14+
integer,parameter :: n = 100
15+
16+
real(wp), dimension(:),allocatable :: x !! x values
17+
real(wp), dimension(:),allocatable :: y !! y values
18+
real(wp), dimension(:),allocatable :: xerr !! error values
19+
real(wp), dimension(:),allocatable :: yerr !! error values for bar chart
20+
real(wp), dimension(:),allocatable :: sx !! sin(x) values
21+
real(wp), dimension(:),allocatable :: cx !! cos(x) values
22+
real(wp), dimension(:),allocatable :: zx !!
23+
real(wp), dimension(:),allocatable :: tx !! sin(x)*cos(x) values
24+
real(wp), dimension(:,:),allocatable :: z !! z matrix for contour plot
25+
real(wp), dimension(:,:),allocatable :: mat !! image values
26+
type(pyplot) :: plt !! pytplot handler
27+
integer :: i !! counter
28+
integer :: j !! counter
29+
real(wp) :: r2 !! temp variable
30+
integer :: istat !! status code
31+
32+
real(wp),parameter :: pi = acos(-1.0_wp)
33+
real(wp),parameter :: deg2rad = pi/180.0_wp
34+
35+
character(len=*), parameter :: testdir = "test/"
36+
37+
! size arrays:
38+
allocate(x(n))
39+
allocate(y(n))
40+
allocate(yerr(n))
41+
allocate(sx(n))
42+
allocate(cx(n))
43+
allocate(zx(n))
44+
allocate(tx(n))
45+
allocate(z(n,n))
46+
allocate(mat(n,n))
47+
48+
!generate some data:
49+
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
50+
sx = sin(x)
51+
cx = cos(x)
52+
tx = sx * cx
53+
zx = 0.0_wp
54+
yerr = abs(sx*.25_wp)
55+
56+
do i=1,n
57+
do j=1,n
58+
mat(i,j) = sin(real(i,wp)*real(j,wp))
59+
end do
60+
end do
61+
62+
!2d line plot:
63+
call plt%initialize(grid=.true.,xlabel='angle (rad)',figsize=[20,10],&
64+
title='plot test',legend=.true.,axis_equal=.true.,&
65+
tight_layout=.true.)
66+
call plt%add_plot(x,sx,label='$\sin (x)$',linestyle='b-o',markersize=5,linewidth=2,istat=istat)
67+
call plt%add_plot(x,cx,label='$\cos (x)$',linestyle='r-o',markersize=5,linewidth=2,istat=istat)
68+
call plt%add_plot(x,tx,label='$\sin (x) \cos (x)$',linestyle='g-o',markersize=2,linewidth=1,istat=istat)
69+
call plt%savefig(testdir//'plottest.png', pyfile=testdir//'plottest.py',&
70+
istat=istat)
71+
72+
!bar chart:
73+
tx = 0.1_wp !for bar width
74+
call plt%initialize(grid=.true.,xlabel='angle (rad)',&
75+
title='bar test',legend=.true.,figsize=[20,10],&
76+
font_size = 20,&
77+
axes_labelsize = 20,&
78+
xtick_labelsize = 20,&
79+
ytick_labelsize = 20,&
80+
legend_fontsize = 20, raw_strings=.true. )
81+
call plt%add_bar(x=x,height=sx,width=tx,label='$\sin (x)$',&
82+
color='r',yerr=yerr,xlim=[0.0_wp, 20.0_wp],align='center',istat=istat)
83+
call plt%savefig(testdir//'bartest.png', pyfile=testdir//'bartest.py',&
84+
istat=istat)
85+
86+
!contour plot:
87+
x = [(real(i,wp), i=0,n-1)]/100.0_wp
88+
y = [(real(i,wp), i=0,n-1)]/100.0_wp
89+
do i=1,n
90+
do j=1,n
91+
r2 = x(i)**2 + y(j)**2
92+
z(i,j) = sin(x(i))*cos(y(j))*sin(r2)/(1.0_wp+log(r2+1.0_wp))
93+
end do
94+
end do
95+
call plt%initialize(grid=.true.,xlabel='x angle (rad)',&
96+
ylabel='y angle (rad)',figsize=[10,10],&
97+
title='Contour plot test', real_fmt='*',&
98+
axisbelow=.false.)
99+
call plt%add_contour(x, y, z, linestyle='-', &
100+
filled=.true., cmap='bone', colorbar=.true.,&
101+
istat=istat)
102+
call plt%savefig(testdir//'contour.png',pyfile=testdir//'contour.py',istat=istat)
103+
104+
!image plot:
105+
call plt%initialize(grid=.true.,xlabel='x',ylabel='y',figsize=[20,20],&
106+
title='imshow test',&
107+
real_fmt='(F9.3)')
108+
call plt%add_imshow(mat,xlim=[0.0_wp, 100.0_wp],ylim=[0.0_wp, 100.0_wp],istat=istat)
109+
call plt%savefig(testdir//'imshow.png', pyfile=testdir//'imshow.py',&
110+
istat=istat)
111+
112+
!wireframe plot:
113+
call plt%initialize(grid=.true.,xlabel='x angle (rad)',&
114+
ylabel='y angle (rad)',figsize=[10,10],&
115+
title='Wireframe plot test', real_fmt='*',&
116+
axisbelow=.false.,mplot3d=.true.,use_numpy=.true.)
117+
call plt%plot_wireframe(x, y, z, label='', linestyle='-', &
118+
cmap='bone', colorbar=.true.,&
119+
istat=istat)
120+
call plt%savefig(testdir//'wireframe.png', pyfile=testdir//'wireframe.py',&
121+
istat=istat)
122+
123+
!histogram chart:
124+
x = [0.194,0.501,-1.241,1.425,-2.217,-0.342,-0.979,0.909,0.994,0.101, &
125+
-0.131,-0.627,0.463,1.404,0.036,-2.000,0.109,1.250,-1.035,-1.115, &
126+
0.935,0.496,1.100,0.770,-1.307,-0.693,-0.072,-1.331,-0.701, &
127+
-0.494,0.666,-0.313,-0.430,-0.654,1.638,-0.334,-0.418,0.550,-0.034, &
128+
0.473,0.704,0.801,-0.157,0.055,-0.057,-1.049,-1.022,0.495,0.756, &
129+
0.149,0.543,-0.813,-0.171,-0.994,-1.532,0.502,1.324,-0.593,-0.467, &
130+
0.372,-0.904,1.255,0.931,-0.779,1.529,-0.036,0.783,0.292,-0.792, &
131+
-0.223,-0.325,0.225,-0.492,-0.941,0.065,1.300,-1.241,-1.124,-0.499, &
132+
1.233,-0.845,-0.948,-1.060,1.103,-1.154,-0.594,0.335,-1.423,0.571, &
133+
-0.903,1.129,-0.372,-1.043,-1.327,0.147,1.056,1.068,-0.699,0.988,-0.630]
134+
135+
call plt%initialize(grid=.true.,xlabel='x',&
136+
title='hist test',&
137+
legend=.true.,figsize=[20,10],&
138+
font_size = 20,&
139+
axes_labelsize = 20,&
140+
xtick_labelsize = 20,&
141+
ytick_labelsize = 20,&
142+
legend_fontsize = 20 )
143+
144+
call plt%add_hist(x=x, label='x',istat=istat)
145+
call plt%savefig(testdir//'histtest1.png', pyfile=testdir//'histtest1.py',&
146+
istat=istat)
147+
148+
call plt%initialize(grid=.true.,xlabel='x',&
149+
title='cumulative hist test',&
150+
legend=.true.,figsize=[20,10],&
151+
font_size = 20,&
152+
axes_labelsize = 20,&
153+
xtick_labelsize = 20,&
154+
ytick_labelsize = 20,&
155+
legend_fontsize = 20 )
156+
157+
call plt%add_hist(x=x, label='x', bins=8, cumulative=.true.,istat=istat)
158+
call plt%savefig(testdir//'histtest2.png', &
159+
pyfile=testdir//'histtest2.py', &
160+
dpi='200', &
161+
transparent=.true.,istat=istat)
162+
163+
!3D plot:
164+
call plt%initialize(grid=.true.,&
165+
xlabel='x (km)',ylabel='y (km)',zlabel='z (km)',&
166+
title='Orbit',&
167+
axis_equal=.true.,&
168+
mplot3d=.true.,&
169+
figsize=[20,10] )
170+
171+
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
172+
sx = 7000.0_wp * cos(x * deg2rad)
173+
cx = 7000.0_wp * sin(x * deg2rad)
174+
zx = 0.0_wp
175+
call plt%add_3d_plot(sx,cx,zx,&
176+
label='orbit',linestyle='r-',&
177+
linewidth=2,istat=istat)
178+
call plt%add_sphere(6378.0_wp,0.0_wp,0.0_wp,0.0_wp,&
179+
color='Blue',n_facets=500,&
180+
antialiased=.true.,istat=istat)
181+
call plt%savefig(testdir//'orbit.png', &
182+
pyfile=testdir//'orbit.py', &
183+
dpi='200', &
184+
transparent=.true.,istat=istat)
185+
186+
! Errorbar plot:
187+
call plt%initialize(grid=.true.,&
188+
xlabel='x',ylabel='y',&
189+
title='Errorbar Plot Example',&
190+
figsize=[20,10] )
191+
192+
x = [(real(i,wp), i=0, 360, 10)]
193+
y = 10.0_wp * cos(x * deg2rad)
194+
xerr = abs(sin(x * deg2rad) * 5.0_wp)
195+
yerr = abs(sin(y * deg2rad) * 10.0_wp)
196+
197+
call plt%add_errorbar(x, y, label='y', linestyle='.', &
198+
xerr=xerr, yerr=yerr, istat=istat)
199+
call plt%savefig(testdir//'errorbar.png', &
200+
pyfile=testdir//'errorbar.py', &
201+
dpi='200', &
202+
transparent=.true.,istat=istat, python='python')
203+
204+
end program test
205+
!*****************************************************************************************

0 commit comments

Comments
 (0)
Please sign in to comment.