From a8ad99606ababda3d61c1d772f68fb7c637d4639 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Wed, 27 Mar 2024 13:15:17 -0500 Subject: [PATCH] updates Fixed a test with latest matplotlib. Fixes #47 Added a new option to use date formatting for the axes. --- .gitignore | 83 ++++----- src/pyplot_module.F90 | 31 +++- test/date_test.f90 | 50 ++++++ test/test.f90 | 410 +++++++++++++++++++++--------------------- 4 files changed, 324 insertions(+), 250 deletions(-) create mode 100644 test/date_test.f90 diff --git a/.gitignore b/.gitignore index 9ab15fe..0113cb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,41 +1,42 @@ -bin/ -lib/ -doc/ -build/ -__pycache__ - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# Generated Test Files -test/*.png -test/*.py - -# misc -.DS_Store +bin/ +lib/ +doc/ +build/ +__pycache__ + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Generated Test Files +test/*.png +test/*.py + +# misc +.DS_Store +/env \ No newline at end of file diff --git a/src/pyplot_module.F90 b/src/pyplot_module.F90 index ff13285..fa5a767 100644 --- a/src/pyplot_module.F90 +++ b/src/pyplot_module.F90 @@ -71,6 +71,9 @@ module pyplot_module logical :: tight_layout = .false. !! tight layout option logical :: usetex = .false. !! enable LaTeX + character(len=:),allocatable :: xaxis_date_fmt !! date format for the x-axis. Example: `"%m/%d/%y %H:%M:%S"` + character(len=:),allocatable :: yaxis_date_fmt !! date format for the y-axis. Example: `"%m/%d/%y %H:%M:%S"` + character(len=:),allocatable :: real_fmt !! real number formatting contains @@ -162,7 +165,7 @@ end subroutine add_str subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy, figsize, & font_size, axes_labelsize, xtick_labelsize, ytick_labelsize, ztick_labelsize, & legend_fontsize, mplot3d, axis_equal, polar, real_fmt, use_oo_api, axisbelow,& - tight_layout, raw_strings, usetex) + tight_layout, raw_strings, usetex, xaxis_date_fmt, yaxis_date_fmt) class(pyplot), intent(inout) :: me !! pyplot handler logical, intent(in), optional :: grid !! activate grid drawing @@ -189,6 +192,8 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy logical, intent(in), optional :: raw_strings !! if True, all strings sent to Python are treated as !! raw strings (e.g., r'str'). Default is False. logical, intent(in), optional :: usetex !! if True, enable LaTeX. (default if false) + character(len=*), intent(in), optional :: xaxis_date_fmt !! if present, used to set the date format for the x-axis + character(len=*), intent(in), optional :: yaxis_date_fmt !! if present, used to set the date format for the y-axis character(len=max_int_len) :: width_str !! figure width dummy string 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 else me%usetex = .false. end if + if (present(xaxis_date_fmt)) then + me%xaxis_date_fmt = xaxis_date_fmt + else + if (allocated(me%xaxis_date_fmt)) deallocate(me%xaxis_date_fmt) + end if + if (present(yaxis_date_fmt)) then + me%yaxis_date_fmt = yaxis_date_fmt + else + if (allocated(me%yaxis_date_fmt)) deallocate(me%yaxis_date_fmt) + end if call optional_int_to_string(font_size, font_size_str, default_font_size_str) call optional_int_to_string(axes_labelsize, axes_labelsize_str, default_font_size_str) @@ -1401,11 +1416,11 @@ subroutine execute(me, pyfile, istat, python) write(error_unit,'(A)') 'Error closing file: '//trim(file) else - if (present(python)) then + if (present(python)) then python_ = trim(python) - else + else python_ = python_exe - end if + end if !run the file using python: if (index(file,' ')>0) then @@ -1477,6 +1492,14 @@ subroutine finish_ops(me) end if call me%add_str('') end if + if (allocated(me%xaxis_date_fmt) .or. allocated(me%yaxis_date_fmt)) then + call me%add_str('from matplotlib.dates import DateFormatter') + if (allocated(me%xaxis_date_fmt)) & + call me%add_str('ax.xaxis.set_major_formatter(DateFormatter("'//trim(me%xaxis_date_fmt)//'"))') + if (allocated(me%yaxis_date_fmt)) & + call me%add_str('ax.yaxis.set_major_formatter(DateFormatter("'//trim(me%yaxis_date_fmt)//'"))') + call me%add_str('') + end if if (me%tight_layout) then call me%add_str('fig.tight_layout()') call me%add_str('') diff --git a/test/date_test.f90 b/test/date_test.f90 new file mode 100644 index 0000000..7c4516e --- /dev/null +++ b/test/date_test.f90 @@ -0,0 +1,50 @@ +!***************************************************************************************** +!> +! Unit test for [[pyplot_module]]. Using the `xaxis_date_fmt` option for x-axis dates. + + program date_test + + use pyplot_module, only : pyplot, wp => pyplot_wp + + implicit none + + integer,parameter :: n = 100 + + real(wp), dimension(:),allocatable :: x !! x values + real(wp), dimension(:),allocatable :: y !! y values + real(wp), dimension(:),allocatable :: sx !! sin(x) values + real(wp), dimension(:),allocatable :: cx !! cos(x) values + real(wp), dimension(:),allocatable :: tx !! sin(x)*cos(x) values + type(pyplot) :: plt !! pytplot handler + integer :: i !! counter + integer :: istat !! status code + + character(len=*), parameter :: testdir = "test/" + character(len=*), parameter :: xaxis_date_fmt = '%m/%d/%y %H:%M:%S' + character(len=*), parameter :: yaxis_date_fmt = '%H:%M:%S' + + ! size arrays: + allocate(x(n)) + allocate(sx(n)) + allocate(cx(n)) + allocate(tx(n)) + + !generate some data: + x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp + sx = 10*sin(x) + cx = cos(x) + tx = sx * cx + + !2d line plot: + call plt%initialize(grid=.true.,xlabel='Calendar date',figsize=[20,10],& + title='date test',legend=.true.,axis_equal=.true.,& + tight_layout=.true., & + xaxis_date_fmt=xaxis_date_fmt, yaxis_date_fmt=yaxis_date_fmt) + call plt%add_plot(x,sx,label='$\sin (x)$',linestyle='b-o',markersize=5,linewidth=2,istat=istat) + call plt%add_plot(x,cx,label='$\cos (x)$',linestyle='r-o',markersize=5,linewidth=2,istat=istat) + call plt%add_plot(x,tx,label='$\sin (x) \cos (x)$',linestyle='g-o',markersize=2,linewidth=1,istat=istat) + call plt%savefig(testdir//'datetest.png', pyfile=testdir//'datetest.py',& + istat=istat) + + end program date_test +!***************************************************************************************** diff --git a/test/test.f90 b/test/test.f90 index c2f49d8..7f48b1d 100644 --- a/test/test.f90 +++ b/test/test.f90 @@ -1,205 +1,205 @@ -!***************************************************************************************** -!> author: Jacob Williams -! date: 4/14/2015 -! license: BSD -! -! Unit test for [[pyplot_module]]. - - program test - - use pyplot_module, only : pyplot, wp => pyplot_wp - - implicit none - - integer,parameter :: n = 100 - - real(wp), dimension(:),allocatable :: x !! x values - real(wp), dimension(:),allocatable :: y !! y values - real(wp), dimension(:),allocatable :: xerr !! error values - real(wp), dimension(:),allocatable :: yerr !! error values for bar chart - real(wp), dimension(:),allocatable :: sx !! sin(x) values - real(wp), dimension(:),allocatable :: cx !! cos(x) values - real(wp), dimension(:),allocatable :: zx !! - real(wp), dimension(:),allocatable :: tx !! sin(x)*cos(x) values - real(wp), dimension(:,:),allocatable :: z !! z matrix for contour plot - real(wp), dimension(:,:),allocatable :: mat !! image values - type(pyplot) :: plt !! pytplot handler - integer :: i !! counter - integer :: j !! counter - real(wp) :: r2 !! temp variable - integer :: istat !! status code - - real(wp),parameter :: pi = acos(-1.0_wp) - real(wp),parameter :: deg2rad = pi/180.0_wp - - character(len=*), parameter :: testdir = "test/" - - ! size arrays: - allocate(x(n)) - allocate(y(n)) - allocate(yerr(n)) - allocate(sx(n)) - allocate(cx(n)) - allocate(zx(n)) - allocate(tx(n)) - allocate(z(n,n)) - allocate(mat(n,n)) - - !generate some data: - x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp - sx = sin(x) - cx = cos(x) - tx = sx * cx - zx = 0.0_wp - yerr = abs(sx*.25_wp) - - do i=1,n - do j=1,n - mat(i,j) = sin(real(i,wp)*real(j,wp)) - end do - end do - - !2d line plot: - call plt%initialize(grid=.true.,xlabel='angle (rad)',figsize=[20,10],& - title='plot test',legend=.true.,axis_equal=.true.,& - tight_layout=.true.) - call plt%add_plot(x,sx,label='$\sin (x)$',linestyle='b-o',markersize=5,linewidth=2,istat=istat) - call plt%add_plot(x,cx,label='$\cos (x)$',linestyle='r-o',markersize=5,linewidth=2,istat=istat) - call plt%add_plot(x,tx,label='$\sin (x) \cos (x)$',linestyle='g-o',markersize=2,linewidth=1,istat=istat) - call plt%savefig(testdir//'plottest.png', pyfile=testdir//'plottest.py',& - istat=istat) - - !bar chart: - tx = 0.1_wp !for bar width - call plt%initialize(grid=.true.,xlabel='angle (rad)',& - title='bar test',legend=.true.,figsize=[20,10],& - font_size = 20,& - axes_labelsize = 20,& - xtick_labelsize = 20,& - ytick_labelsize = 20,& - legend_fontsize = 20, raw_strings=.true. ) - call plt%add_bar(x=x,height=sx,width=tx,label='$\sin (x)$',& - color='r',yerr=yerr,xlim=[0.0_wp, 20.0_wp],align='center',istat=istat) - call plt%savefig(testdir//'bartest.png', pyfile=testdir//'bartest.py',& - istat=istat) - - !contour plot: - x = [(real(i,wp), i=0,n-1)]/100.0_wp - y = [(real(i,wp), i=0,n-1)]/100.0_wp - do i=1,n - do j=1,n - r2 = x(i)**2 + y(j)**2 - z(i,j) = sin(x(i))*cos(y(j))*sin(r2)/(1.0_wp+log(r2+1.0_wp)) - end do - end do - call plt%initialize(grid=.true.,xlabel='x angle (rad)',& - ylabel='y angle (rad)',figsize=[10,10],& - title='Contour plot test', real_fmt='*',& - axisbelow=.false.) - call plt%add_contour(x, y, z, linestyle='-', & - filled=.true., cmap='bone', colorbar=.true.,& - istat=istat) - call plt%savefig(testdir//'contour.png',pyfile=testdir//'contour.py',istat=istat) - - !image plot: - call plt%initialize(grid=.true.,xlabel='x',ylabel='y',figsize=[20,20],& - title='imshow test',& - real_fmt='(F9.3)') - call plt%add_imshow(mat,xlim=[0.0_wp, 100.0_wp],ylim=[0.0_wp, 100.0_wp],istat=istat) - call plt%savefig(testdir//'imshow.png', pyfile=testdir//'imshow.py',& - istat=istat) - - !wireframe plot: - call plt%initialize(grid=.true.,xlabel='x angle (rad)',& - ylabel='y angle (rad)',figsize=[10,10],& - title='Wireframe plot test', real_fmt='*',& - axisbelow=.false.,mplot3d=.true.,use_numpy=.true.) - call plt%plot_wireframe(x, y, z, label='', linestyle='-', & - cmap='bone', colorbar=.true.,& - istat=istat) - call plt%savefig(testdir//'wireframe.png', pyfile=testdir//'wireframe.py',& - istat=istat) - - !histogram chart: - x = [0.194,0.501,-1.241,1.425,-2.217,-0.342,-0.979,0.909,0.994,0.101, & - -0.131,-0.627,0.463,1.404,0.036,-2.000,0.109,1.250,-1.035,-1.115, & - 0.935,0.496,1.100,0.770,-1.307,-0.693,-0.072,-1.331,-0.701, & - -0.494,0.666,-0.313,-0.430,-0.654,1.638,-0.334,-0.418,0.550,-0.034, & - 0.473,0.704,0.801,-0.157,0.055,-0.057,-1.049,-1.022,0.495,0.756, & - 0.149,0.543,-0.813,-0.171,-0.994,-1.532,0.502,1.324,-0.593,-0.467, & - 0.372,-0.904,1.255,0.931,-0.779,1.529,-0.036,0.783,0.292,-0.792, & - -0.223,-0.325,0.225,-0.492,-0.941,0.065,1.300,-1.241,-1.124,-0.499, & - 1.233,-0.845,-0.948,-1.060,1.103,-1.154,-0.594,0.335,-1.423,0.571, & - -0.903,1.129,-0.372,-1.043,-1.327,0.147,1.056,1.068,-0.699,0.988,-0.630] - - call plt%initialize(grid=.true.,xlabel='x',& - title='hist test',& - legend=.true.,figsize=[20,10],& - font_size = 20,& - axes_labelsize = 20,& - xtick_labelsize = 20,& - ytick_labelsize = 20,& - legend_fontsize = 20 ) - - call plt%add_hist(x=x, label='x',istat=istat) - call plt%savefig(testdir//'histtest1.png', pyfile=testdir//'histtest1.py',& - istat=istat) - - call plt%initialize(grid=.true.,xlabel='x',& - title='cumulative hist test',& - legend=.true.,figsize=[20,10],& - font_size = 20,& - axes_labelsize = 20,& - xtick_labelsize = 20,& - ytick_labelsize = 20,& - legend_fontsize = 20 ) - - call plt%add_hist(x=x, label='x', bins=8, cumulative=.true.,istat=istat) - call plt%savefig(testdir//'histtest2.png', & - pyfile=testdir//'histtest2.py', & - dpi='200', & - transparent=.true.,istat=istat) - - !3D plot: - call plt%initialize(grid=.true.,& - xlabel='x (km)',ylabel='y (km)',zlabel='z (km)',& - title='Orbit',& - axis_equal=.true.,& - mplot3d=.true.,& - figsize=[20,10] ) - - x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp - sx = 7000.0_wp * cos(x * deg2rad) - cx = 7000.0_wp * sin(x * deg2rad) - zx = 0.0_wp - call plt%add_3d_plot(sx,cx,zx,& - label='orbit',linestyle='r-',& - linewidth=2,istat=istat) - call plt%add_sphere(6378.0_wp,0.0_wp,0.0_wp,0.0_wp,& - color='Blue',n_facets=500,& - antialiased=.true.,istat=istat) - call plt%savefig(testdir//'orbit.png', & - pyfile=testdir//'orbit.py', & - dpi='200', & - transparent=.true.,istat=istat) - - ! Errorbar plot: - call plt%initialize(grid=.true.,& - xlabel='x',ylabel='y',& - title='Errorbar Plot Example',& - figsize=[20,10] ) - - x = [(real(i,wp), i=0, 360, 10)] - y = 10.0_wp * cos(x * deg2rad) - xerr = sin(x * deg2rad) * 5.0_wp - yerr = sin(y * deg2rad) * 10.0_wp - - call plt%add_errorbar(x, y, label='y', linestyle='.', & - xerr=xerr, yerr=yerr, istat=istat) - call plt%savefig(testdir//'errorbar.png', & - pyfile=testdir//'errorbar.py', & - dpi='200', & - transparent=.true.,istat=istat, python='python') - - end program test -!***************************************************************************************** +!***************************************************************************************** +!> author: Jacob Williams +! date: 4/14/2015 +! license: BSD +! +! Unit test for [[pyplot_module]]. + + program test + + use pyplot_module, only : pyplot, wp => pyplot_wp + + implicit none + + integer,parameter :: n = 100 + + real(wp), dimension(:),allocatable :: x !! x values + real(wp), dimension(:),allocatable :: y !! y values + real(wp), dimension(:),allocatable :: xerr !! error values + real(wp), dimension(:),allocatable :: yerr !! error values for bar chart + real(wp), dimension(:),allocatable :: sx !! sin(x) values + real(wp), dimension(:),allocatable :: cx !! cos(x) values + real(wp), dimension(:),allocatable :: zx !! + real(wp), dimension(:),allocatable :: tx !! sin(x)*cos(x) values + real(wp), dimension(:,:),allocatable :: z !! z matrix for contour plot + real(wp), dimension(:,:),allocatable :: mat !! image values + type(pyplot) :: plt !! pytplot handler + integer :: i !! counter + integer :: j !! counter + real(wp) :: r2 !! temp variable + integer :: istat !! status code + + real(wp),parameter :: pi = acos(-1.0_wp) + real(wp),parameter :: deg2rad = pi/180.0_wp + + character(len=*), parameter :: testdir = "test/" + + ! size arrays: + allocate(x(n)) + allocate(y(n)) + allocate(yerr(n)) + allocate(sx(n)) + allocate(cx(n)) + allocate(zx(n)) + allocate(tx(n)) + allocate(z(n,n)) + allocate(mat(n,n)) + + !generate some data: + x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp + sx = sin(x) + cx = cos(x) + tx = sx * cx + zx = 0.0_wp + yerr = abs(sx*.25_wp) + + do i=1,n + do j=1,n + mat(i,j) = sin(real(i,wp)*real(j,wp)) + end do + end do + + !2d line plot: + call plt%initialize(grid=.true.,xlabel='angle (rad)',figsize=[20,10],& + title='plot test',legend=.true.,axis_equal=.true.,& + tight_layout=.true.) + call plt%add_plot(x,sx,label='$\sin (x)$',linestyle='b-o',markersize=5,linewidth=2,istat=istat) + call plt%add_plot(x,cx,label='$\cos (x)$',linestyle='r-o',markersize=5,linewidth=2,istat=istat) + call plt%add_plot(x,tx,label='$\sin (x) \cos (x)$',linestyle='g-o',markersize=2,linewidth=1,istat=istat) + call plt%savefig(testdir//'plottest.png', pyfile=testdir//'plottest.py',& + istat=istat) + + !bar chart: + tx = 0.1_wp !for bar width + call plt%initialize(grid=.true.,xlabel='angle (rad)',& + title='bar test',legend=.true.,figsize=[20,10],& + font_size = 20,& + axes_labelsize = 20,& + xtick_labelsize = 20,& + ytick_labelsize = 20,& + legend_fontsize = 20, raw_strings=.true. ) + call plt%add_bar(x=x,height=sx,width=tx,label='$\sin (x)$',& + color='r',yerr=yerr,xlim=[0.0_wp, 20.0_wp],align='center',istat=istat) + call plt%savefig(testdir//'bartest.png', pyfile=testdir//'bartest.py',& + istat=istat) + + !contour plot: + x = [(real(i,wp), i=0,n-1)]/100.0_wp + y = [(real(i,wp), i=0,n-1)]/100.0_wp + do i=1,n + do j=1,n + r2 = x(i)**2 + y(j)**2 + z(i,j) = sin(x(i))*cos(y(j))*sin(r2)/(1.0_wp+log(r2+1.0_wp)) + end do + end do + call plt%initialize(grid=.true.,xlabel='x angle (rad)',& + ylabel='y angle (rad)',figsize=[10,10],& + title='Contour plot test', real_fmt='*',& + axisbelow=.false.) + call plt%add_contour(x, y, z, linestyle='-', & + filled=.true., cmap='bone', colorbar=.true.,& + istat=istat) + call plt%savefig(testdir//'contour.png',pyfile=testdir//'contour.py',istat=istat) + + !image plot: + call plt%initialize(grid=.true.,xlabel='x',ylabel='y',figsize=[20,20],& + title='imshow test',& + real_fmt='(F9.3)') + call plt%add_imshow(mat,xlim=[0.0_wp, 100.0_wp],ylim=[0.0_wp, 100.0_wp],istat=istat) + call plt%savefig(testdir//'imshow.png', pyfile=testdir//'imshow.py',& + istat=istat) + + !wireframe plot: + call plt%initialize(grid=.true.,xlabel='x angle (rad)',& + ylabel='y angle (rad)',figsize=[10,10],& + title='Wireframe plot test', real_fmt='*',& + axisbelow=.false.,mplot3d=.true.,use_numpy=.true.) + call plt%plot_wireframe(x, y, z, label='', linestyle='-', & + cmap='bone', colorbar=.true.,& + istat=istat) + call plt%savefig(testdir//'wireframe.png', pyfile=testdir//'wireframe.py',& + istat=istat) + + !histogram chart: + x = [0.194,0.501,-1.241,1.425,-2.217,-0.342,-0.979,0.909,0.994,0.101, & + -0.131,-0.627,0.463,1.404,0.036,-2.000,0.109,1.250,-1.035,-1.115, & + 0.935,0.496,1.100,0.770,-1.307,-0.693,-0.072,-1.331,-0.701, & + -0.494,0.666,-0.313,-0.430,-0.654,1.638,-0.334,-0.418,0.550,-0.034, & + 0.473,0.704,0.801,-0.157,0.055,-0.057,-1.049,-1.022,0.495,0.756, & + 0.149,0.543,-0.813,-0.171,-0.994,-1.532,0.502,1.324,-0.593,-0.467, & + 0.372,-0.904,1.255,0.931,-0.779,1.529,-0.036,0.783,0.292,-0.792, & + -0.223,-0.325,0.225,-0.492,-0.941,0.065,1.300,-1.241,-1.124,-0.499, & + 1.233,-0.845,-0.948,-1.060,1.103,-1.154,-0.594,0.335,-1.423,0.571, & + -0.903,1.129,-0.372,-1.043,-1.327,0.147,1.056,1.068,-0.699,0.988,-0.630] + + call plt%initialize(grid=.true.,xlabel='x',& + title='hist test',& + legend=.true.,figsize=[20,10],& + font_size = 20,& + axes_labelsize = 20,& + xtick_labelsize = 20,& + ytick_labelsize = 20,& + legend_fontsize = 20 ) + + call plt%add_hist(x=x, label='x',istat=istat) + call plt%savefig(testdir//'histtest1.png', pyfile=testdir//'histtest1.py',& + istat=istat) + + call plt%initialize(grid=.true.,xlabel='x',& + title='cumulative hist test',& + legend=.true.,figsize=[20,10],& + font_size = 20,& + axes_labelsize = 20,& + xtick_labelsize = 20,& + ytick_labelsize = 20,& + legend_fontsize = 20 ) + + call plt%add_hist(x=x, label='x', bins=8, cumulative=.true.,istat=istat) + call plt%savefig(testdir//'histtest2.png', & + pyfile=testdir//'histtest2.py', & + dpi='200', & + transparent=.true.,istat=istat) + + !3D plot: + call plt%initialize(grid=.true.,& + xlabel='x (km)',ylabel='y (km)',zlabel='z (km)',& + title='Orbit',& + axis_equal=.true.,& + mplot3d=.true.,& + figsize=[20,10] ) + + x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp + sx = 7000.0_wp * cos(x * deg2rad) + cx = 7000.0_wp * sin(x * deg2rad) + zx = 0.0_wp + call plt%add_3d_plot(sx,cx,zx,& + label='orbit',linestyle='r-',& + linewidth=2,istat=istat) + call plt%add_sphere(6378.0_wp,0.0_wp,0.0_wp,0.0_wp,& + color='Blue',n_facets=500,& + antialiased=.true.,istat=istat) + call plt%savefig(testdir//'orbit.png', & + pyfile=testdir//'orbit.py', & + dpi='200', & + transparent=.true.,istat=istat) + + ! Errorbar plot: + call plt%initialize(grid=.true.,& + xlabel='x',ylabel='y',& + title='Errorbar Plot Example',& + figsize=[20,10] ) + + x = [(real(i,wp), i=0, 360, 10)] + y = 10.0_wp * cos(x * deg2rad) + xerr = abs(sin(x * deg2rad) * 5.0_wp) + yerr = abs(sin(y * deg2rad) * 10.0_wp) + + call plt%add_errorbar(x, y, label='y', linestyle='.', & + xerr=xerr, yerr=yerr, istat=istat) + call plt%savefig(testdir//'errorbar.png', & + pyfile=testdir//'errorbar.py', & + dpi='200', & + transparent=.true.,istat=istat, python='python') + + end program test +!*****************************************************************************************