@@ -46,6 +46,7 @@ module pyplot_module
4646 logical :: axis_equal = .false. ! ! equal scale on each axis
4747 logical :: axisbelow = .true. ! ! axis below other chart elements
4848 logical :: tight_layout = .false. ! ! tight layout option
49+ logical :: usetex = .false. ! ! enable LaTeX
4950
5051 character (len= :),allocatable :: real_fmt ! ! real number formatting
5152
@@ -117,7 +118,7 @@ end subroutine add_str
117118 subroutine initialize (me , grid , xlabel , ylabel , zlabel , title , legend , use_numpy , figsize , &
118119 font_size , axes_labelsize , xtick_labelsize , ytick_labelsize , ztick_labelsize , &
119120 legend_fontsize , mplot3d , axis_equal , polar , real_fmt , use_oo_api , axisbelow ,&
120- tight_layout , raw_strings )
121+ tight_layout , raw_strings , usetex )
121122
122123 class(pyplot), intent (inout ) :: me ! ! pyplot handler
123124 logical , intent (in ), optional :: grid ! ! activate grid drawing
@@ -143,6 +144,7 @@ subroutine initialize(me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy
143144 logical , intent (in ), optional :: tight_layout ! ! enable tight layout [default is false]
144145 logical , intent (in ), optional :: raw_strings ! ! if True, all strings sent to Python are treated as
145146 ! ! raw strings (e.g., r'str'). Default is False.
147+ logical , intent (in ), optional :: usetex ! ! if True, enable LaTeX. (default if false)
146148
147149 character (len= max_int_len) :: width_str ! ! figure width dummy string
148150 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
206208 else
207209 me% tight_layout = .false.
208210 end if
211+ if (present (usetex)) then
212+ me% usetex = usetex
213+ else
214+ me% usetex = .false.
215+ end if
209216
210217 call optional_int_to_string(font_size, font_size_str, default_font_size_str)
211218 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
236243 call me% add_str(' matplotlib.rcParams["xtick.labelsize"] = ' // trim (xtick_labelsize_str))
237244 call me% add_str(' matplotlib.rcParams["ytick.labelsize"] = ' // trim (ytick_labelsize_str))
238245 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' )
239247
240248 call me% add_str(' ' )
241249
0 commit comments