@@ -712,9 +712,10 @@ def configure_fds_fonts(**kwargs):
712712 import matplotlib .pyplot as plt
713713 import platform
714714
715- system = platform .system ()
716715 use_tex = kwargs .get ('usetex' , False )
716+ system = platform .system ()
717717
718+ # OS-dependent serif stack
718719 if system == "Linux" :
719720 primary_serif = "Nimbus Roman"
720721 serif_list = [
@@ -732,33 +733,50 @@ def configure_fds_fonts(**kwargs):
732733 "serif" ,
733734 ]
734735
735- plt .rcParams .update ({
736- "pdf.use14corefonts" : True ,
737- "text.usetex" : use_tex ,
736+ # ------------------------------------------------------------
737+ # Core default config (applies to BOTH branches)
738+ # ------------------------------------------------------------
739+ rc = {
740+ "pdf.use14corefonts" : True , # use Base-14 when possible
741+ "text.usetex" : use_tex , # route text through TeX or not
738742
739743 "font.family" : "serif" ,
740744 "font.serif" : serif_list ,
741745 "font.sans-serif" : serif_list ,
742746
743- # Mathtext still matters when text.usetex=False
744- "mathtext.fontset" : "custom" ,
745- "mathtext.rm" : primary_serif ,
746- "mathtext.it" : f"{ primary_serif } :italic" ,
747- "mathtext.bf" : f"{ primary_serif } :bold" ,
748- "mathtext.cal" : f"{ primary_serif } :italic" ,
749- "mathtext.tt" : "Courier" ,
750- "mathtext.default" : "rm" ,
751-
752747 "axes.unicode_minus" : False ,
753748 "pdf.compression" : 9 ,
754- })
749+ }
755750
756- # Only for usetex=True, insert packages that Times-ify math
757- if use_tex :
758- plt .rcParams ["text.latex.preamble" ] = r"""
759- \usepackage{newtxtext}
760- \usepackage{newtxmath}
761- """
751+ # ------------------------------------------------------------
752+ # Branch A: NON-TeX Mode (usetex=False)
753+ # Use mathtext for math, STIX for math glyphs
754+ # Keep Times/Nimbus for normal text
755+ # Very small PDFs
756+ # ------------------------------------------------------------
757+ if not use_tex :
758+ rc .update ({
759+ "mathtext.fontset" : "stix" ,
760+ "mathtext.default" : "it" , # italic math by default
761+ })
762+
763+ # ------------------------------------------------------------
764+ # Branch B: Full TeX rendering (usetex=True)
765+ # - Times for body
766+ # - newtxtext/newtxmath to Times-ify math
767+ # - Disable STIX mathtext completely
768+ # ------------------------------------------------------------
769+ else :
770+ rc .update ({
771+ "mathtext.fontset" : "cm" , # or "custom" — anything NOT stix
772+ "mathtext.default" : "rm" , # don't auto-italic mathtext in TeX mode
773+ "text.latex.preamble" : r"""
774+ \usepackage{newtxtext}
775+ \usepackage{newtxmath}
776+ """ ,
777+ })
778+
779+ plt .rcParams .update (rc )
762780
763781
764782def plot_to_fig (x_data ,y_data ,** kwargs ):
@@ -1037,6 +1055,7 @@ def plot_to_fig(x_data,y_data,**kwargs):
10371055 plt .setp ( ax .yaxis .get_majorticklabels (), rotation = 0 , fontsize = ticklabel_fontsize )
10381056
10391057 axeslabel_fontsize = kwargs .get ('axeslabel_fontsize' ,default_axeslabel_fontsize )
1058+
10401059 if not using_existing_figure :
10411060 plt .xlabel (kwargs .get ('x_label' ), fontsize = axeslabel_fontsize )
10421061 plt .ylabel (kwargs .get ('y_label' ), fontsize = axeslabel_fontsize )
0 commit comments