@@ -42,6 +42,7 @@ module pyplot_module
4242 logical :: mplot3d = .false. ! ! it is a 3d plot
4343 logical :: polar = .false. ! ! it is a polar plot
4444 logical :: axis_equal = .false. ! ! equal scale on each axis
45+ logical :: axisbelow = .true. ! ! axis below other chart elements
4546
4647 character (len= :),allocatable :: real_fmt ! ! real number formatting
4748
@@ -108,7 +109,7 @@ end subroutine add_str
108109
109110 subroutine initialize (me , grid , xlabel , ylabel , zlabel , title , legend , use_numpy , figsize , &
110111 font_size , axes_labelsize , xtick_labelsize , ytick_labelsize , ztick_labelsize , &
111- legend_fontsize , mplot3d , axis_equal , polar , real_fmt , use_oo_api )
112+ legend_fontsize , mplot3d , axis_equal , polar , real_fmt , use_oo_api , axisbelow )
112113
113114 class(pyplot), intent (inout ) :: me ! ! pyplot handler
114115 logical , intent (in ), optional :: grid ! ! activate grid drawing
@@ -130,6 +131,7 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
130131 logical , intent (in ), optional :: polar ! ! set true for polar plots (cannot use with mplot3d)
131132 character (len=* ), intent (in ), optional :: real_fmt ! ! format string for real numbers (examples: '(E30.16)' [default], '*')
132133 logical , intent (in ), optional :: use_oo_api ! ! avoid matplotlib's GUI by using the OO interface (cannot use with showfig)
134+ logical , intent (in ), optional :: axisbelow ! ! to put the grid lines below the other chart elements [default is true]
133135
134136 character (len= max_int_len) :: width_str ! ! figure width dummy string
135137 character (len= max_int_len) :: height_str ! ! figure height dummy string
@@ -240,6 +242,13 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
240242 if (grid) call me% add_str(' ax.grid()' )
241243 end if
242244
245+ if (present (axisbelow)) then
246+ me% axisbelow = axisbelow
247+ else
248+ me% axisbelow = .true. ! default
249+ end if
250+ if (me% axisbelow) call me% add_str(' ax.set_axisbelow(True)' )
251+
243252 if (present (xlabel)) call me% add_str(' ax.set_xlabel("' // trim (xlabel)// ' ")' )
244253 if (present (ylabel)) call me% add_str(' ax.set_ylabel("' // trim (ylabel)// ' ")' )
245254 if (present (zlabel)) call me% add_str(' ax.set_zlabel("' // trim (zlabel)// ' ")' )
0 commit comments