@@ -1101,12 +1101,6 @@ def plot_to_fig(x_data,y_data,**kwargs):
11011101 if xticks is not None : ax .set_xticks (xticks )
11021102 if yticks is not None : ax .set_yticks (yticks )
11031103
1104- # # apply exponent for log axes
1105- # if plot_type in ('loglog', 'semilogy'):
1106- # apply_global_exponent(ax, axis='y', fontsize=axeslabel_fontsize)
1107- # if plot_type in ('loglog', 'semilogx'):
1108- # apply_global_exponent(ax, axis='x', fontsize=axeslabel_fontsize)
1109-
11101104 if kwargs .get ('revision_label' ):
11111105 add_version_string (ax = ax , version_str = kwargs .get ('revision_label' ), plot_type = plot_type , font_size = version_fontsize )
11121106
@@ -1117,70 +1111,6 @@ def plot_to_fig(x_data,y_data,**kwargs):
11171111 return fig
11181112
11191113
1120- def apply_global_exponent (ax , axis = 'y' , fontsize = 10 , minor_subs = None ):
1121- import numpy as np
1122- from matplotlib .ticker import FuncFormatter , LogLocator
1123-
1124- if axis == 'y' :
1125- ticks = ax .get_yticks ()
1126- axis_obj = ax .yaxis
1127- lims = ax .get_ylim ()
1128- else :
1129- ticks = ax .get_xticks ()
1130- axis_obj = ax .xaxis
1131- lims = ax .get_xlim ()
1132-
1133- # Keep only positive finite ticks (for log axes)
1134- ticks = np .array ([t for t in ticks if t > 0 and np .isfinite (t )])
1135- if ticks .size == 0 :
1136- return
1137-
1138- # Choose representative exponent
1139- exp = int (np .floor (np .log10 (np .median (ticks ))))
1140- scale = 10.0 ** exp
1141-
1142- # Major formatter: fixed-point decimals
1143- def fmt (val , pos ):
1144- v = val / scale
1145- return "{:g}" .format (v )
1146-
1147- axis_obj .set_major_formatter (FuncFormatter (fmt ))
1148- axis_obj .get_offset_text ().set_visible (False )
1149-
1150- # Decide what to do with minor tick labels
1151- span_decades = np .log10 (lims [1 ]) - np .log10 (max (lims [0 ], 1e-300 ))
1152-
1153- # Default subs = 2, 4, 6, 8
1154- if minor_subs is None :
1155- minor_subs = [2 , 4 , 6 , 8 ]
1156-
1157- if span_decades <= 1.1 : # only ~1 decade
1158- axis_obj .set_minor_locator (LogLocator (base = 10.0 , subs = minor_subs , numticks = 10 ))
1159- axis_obj .set_minor_formatter (FuncFormatter (lambda val , pos : "{:g}" .format (val / scale )))
1160- else :
1161- ax .tick_params (axis = axis , which = 'minor' , labelleft = False , labelbottom = False )
1162-
1163- # Force tick labels NOT to go through TeX
1164- if axis == 'y' :
1165- for label in ax .get_yticklabels () + ax .get_yticklabels (minor = True ):
1166- label .set_usetex (False )
1167- else :
1168- for label in ax .get_xticklabels () + ax .get_xticklabels (minor = True ):
1169- label .set_usetex (False )
1170-
1171- # Place the ×10^exp text at the axis end
1172- if exp != 0 :
1173- if axis == 'y' :
1174- ax .text (0 , 1.01 , rf"$\times 10^{{{ exp } }}$" ,
1175- transform = ax .transAxes ,
1176- ha = 'left' , va = 'bottom' , fontsize = fontsize )
1177- else :
1178- ax .text (1.0 , - 0.1 , rf"$\times 10^{{{ exp } }}$" ,
1179- transform = ax .transAxes ,
1180- ha = 'right' , va = 'top' , fontsize = fontsize )
1181-
1182-
1183-
11841114def parse_matlab_style (style ):
11851115 color = ''
11861116 marker = ''
0 commit comments