@@ -46,6 +46,7 @@ module pyplot_module
46
46
logical :: axis_equal = .false. ! ! equal scale on each axis
47
47
logical :: axisbelow = .true. ! ! axis below other chart elements
48
48
logical :: tight_layout = .false. ! ! tight layout option
49
+ logical :: usetex = .false. ! ! enable LaTeX
49
50
50
51
character (len= :),allocatable :: real_fmt ! ! real number formatting
51
52
@@ -117,7 +118,7 @@ end subroutine add_str
117
118
subroutine initialize (me , grid , xlabel , ylabel , zlabel , title , legend , use_numpy , figsize , &
118
119
font_size , axes_labelsize , xtick_labelsize , ytick_labelsize , ztick_labelsize , &
119
120
legend_fontsize , mplot3d , axis_equal , polar , real_fmt , use_oo_api , axisbelow ,&
120
- tight_layout , raw_strings )
121
+ tight_layout , raw_strings , usetex )
121
122
122
123
class(pyplot), intent (inout ) :: me ! ! pyplot handler
123
124
logical , intent (in ), optional :: grid ! ! activate grid drawing
@@ -143,6 +144,7 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
143
144
logical , intent (in ), optional :: tight_layout ! ! enable tight layout [default is false]
144
145
logical , intent (in ), optional :: raw_strings ! ! if True, all strings sent to Python are treated as
145
146
! ! raw strings (e.g., r'str'). Default is False.
147
+ logical , intent (in ), optional :: usetex ! ! if True, enable LaTeX. (default if false)
146
148
147
149
character (len= max_int_len) :: width_str ! ! figure width dummy string
148
150
character (len= max_int_len) :: height_str ! ! figure height dummy string
@@ -206,6 +208,11 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
206
208
else
207
209
me% tight_layout = .false.
208
210
end if
211
+ if (present (usetex)) then
212
+ me% usetex = usetex
213
+ else
214
+ me% usetex = .false.
215
+ end if
209
216
210
217
call optional_int_to_string(font_size, font_size_str, default_font_size_str)
211
218
call optional_int_to_string(axes_labelsize, axes_labelsize_str, default_font_size_str)
@@ -236,6 +243,7 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
236
243
call me% add_str(' matplotlib.rcParams["xtick.labelsize"] = ' // trim (xtick_labelsize_str))
237
244
call me% add_str(' matplotlib.rcParams["ytick.labelsize"] = ' // trim (ytick_labelsize_str))
238
245
call me% add_str(' matplotlib.rcParams["legend.fontsize"] = ' // trim (legend_fontsize_str))
246
+ if (me% usetex) call me% add_str(' matplotlib.rcParams["text.usetex"] = True' )
239
247
240
248
call me% add_str(' ' )
241
249
0 commit comments