Skip to content

Commit 8d81edb

Browse files
committed
added support for polar plots
1 parent 5b13776 commit 8d81edb

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/pyplot_module.f90

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module pyplot_module
3939
logical :: show_legend = .false. !! show legend into plot
4040
logical :: use_numpy = .true. !! use numpy python module
4141
logical :: mplot3d = .false. !! it is a 3d plot
42+
logical :: polar = .false. !! it is a polar plot
4243
logical :: axis_equal = .false. !! equal scale on each axis
4344

4445
contains
@@ -99,7 +100,7 @@ end subroutine add_str
99100

100101
subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy, figsize, &
101102
font_size, axes_labelsize, xtick_labelsize, ytick_labelsize, ztick_labelsize, &
102-
legend_fontsize, mplot3d, axis_equal)
103+
legend_fontsize, mplot3d, axis_equal, polar)
103104

104105
class(pyplot), intent(inout) :: me !! pyplot handler
105106
logical, intent(in), optional :: grid !! activate grid drawing
@@ -116,8 +117,9 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
116117
integer, intent(in), optional :: ytick_labelsize !! size of y axis tick lables
117118
integer, intent(in), optional :: ztick_labelsize !! size of z axis tick lables
118119
integer, intent(in), optional :: legend_fontsize !! size of legend font
119-
logical, intent(in), optional :: mplot3d !! set true for 3d plots
120+
logical, intent(in), optional :: mplot3d !! set true for 3d plots (cannot use with polar)
120121
logical, intent(in), optional :: axis_equal !! set true for axis = 'equal'
122+
logical, intent(in), optional :: polar !! set true for polar plots (cannot use with mplot3d)
121123

122124
character(len=max_int_len) :: width_str !! figure width dummy string
123125
character(len=max_int_len) :: height_str !! figure height dummy string
@@ -150,6 +152,11 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
150152
else
151153
me%mplot3d = .false.
152154
end if
155+
if (present(polar)) then
156+
me%polar = polar
157+
else
158+
me%polar = .false.
159+
end if
153160
if (present(axis_equal)) then
154161
me%axis_equal = axis_equal
155162
else
@@ -191,6 +198,8 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
191198

192199
if (me%mplot3d) then
193200
call me%add_str('ax = fig.gca(projection=''3d'')')
201+
elseif (me%polar) then
202+
call me%add_str('ax = fig.gca(projection=''polar'')')
194203
else
195204
call me%add_str('ax = fig.gca()')
196205
end if

src/tests/test.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ program test
1414

1515
real(wp), dimension(100) :: x !! x values
1616
real(wp), dimension(100) :: yerr !! error values for bar chart
17-
real(wp), dimension(100) :: sx !! sin(x) values
18-
real(wp), dimension(100) :: cx !! cos(x) values
19-
real(wp), dimension(100) :: tx !! sin(x)*cos(x) values
20-
type(pyplot) :: plt !! pytplot handler
21-
integer :: i !! counter
17+
real(wp), dimension(100) :: sx !! sin(x) values
18+
real(wp), dimension(100) :: cx !! cos(x) values
19+
real(wp), dimension(100) :: tx !! sin(x)*cos(x) values
20+
type(pyplot) :: plt !! pytplot handler
21+
integer :: i !! counter
2222

2323
!generate some data:
2424
x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp

0 commit comments

Comments
 (0)