@@ -43,6 +43,7 @@ module pyplot_module
43
43
logical :: polar = .false. ! ! it is a polar plot
44
44
logical :: axis_equal = .false. ! ! equal scale on each axis
45
45
logical :: axisbelow = .true. ! ! axis below other chart elements
46
+ logical :: tight_layout = .false. ! ! tight layout option
46
47
47
48
character (len= :),allocatable :: real_fmt ! ! real number formatting
48
49
@@ -109,7 +110,8 @@ end subroutine add_str
109
110
110
111
subroutine initialize (me , grid , xlabel , ylabel , zlabel , title , legend , use_numpy , figsize , &
111
112
font_size , axes_labelsize , xtick_labelsize , ytick_labelsize , ztick_labelsize , &
112
- legend_fontsize , mplot3d , axis_equal , polar , real_fmt , use_oo_api , axisbelow )
113
+ legend_fontsize , mplot3d , axis_equal , polar , real_fmt , use_oo_api , axisbelow ,&
114
+ tight_layout )
113
115
114
116
class(pyplot), intent (inout ) :: me ! ! pyplot handler
115
117
logical , intent (in ), optional :: grid ! ! activate grid drawing
@@ -132,6 +134,7 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
132
134
character (len=* ), intent (in ), optional :: real_fmt ! ! format string for real numbers (examples: '(E30.16)' [default], '*')
133
135
logical , intent (in ), optional :: use_oo_api ! ! avoid matplotlib's GUI by using the OO interface (cannot use with showfig)
134
136
logical , intent (in ), optional :: axisbelow ! ! to put the grid lines below the other chart elements [default is true]
137
+ logical , intent (in ), optional :: tight_layout ! ! enable tight layout [default is false]
135
138
136
139
character (len= max_int_len) :: width_str ! ! figure width dummy string
137
140
character (len= max_int_len) :: height_str ! ! figure height dummy string
@@ -186,6 +189,11 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
186
189
else
187
190
me% real_fmt = real_fmt_default
188
191
end if
192
+ if (present (tight_layout)) then
193
+ me% tight_layout = tight_layout
194
+ else
195
+ me% tight_layout = .false.
196
+ end if
189
197
190
198
call optional_int_to_string(font_size, font_size_str, default_font_size_str)
191
199
call optional_int_to_string(axes_labelsize, axes_labelsize_str, default_font_size_str)
@@ -1096,6 +1104,10 @@ subroutine finish_ops(me)
1096
1104
end if
1097
1105
call me% add_str(' ' )
1098
1106
end if
1107
+ if (me% tight_layout) then
1108
+ call me% add_str(' fig.tight_layout()' )
1109
+ call me% add_str(' ' )
1110
+ end if
1099
1111
1100
1112
end subroutine finish_ops
1101
1113
! *****************************************************************************************
0 commit comments