@@ -424,7 +424,9 @@ def read_csv_cached(path, **kwargs):
424424 y_min = pp .Min_Ind if flip_axis else pp .Min_Dep ,
425425 y_max = pp .Max_Ind if flip_axis else pp .Max_Dep ,
426426 legend_location = matlab_legend_to_matplotlib (pp .Key_Position ),
427+ legend_expand = pp .Paper_Width_Factor ,
427428 plot_type = plot_type ,
429+ plot_title = pp .Plot_Title ,
428430 )
429431
430432 # --- Save measured (experimental) ---
@@ -530,15 +532,6 @@ def read_csv_cached(path, **kwargs):
530532 figure_handle = f , # keep same figure
531533 data_label = d2_key_labels [i ],
532534 line_style = d2_styles [i ],
533- x_label = pp .Dep_Title if flip_axis else pp .Ind_Title ,
534- y_label = pp .Ind_Title if flip_axis else pp .Dep_Title ,
535- x_min = pp .Min_Dep if flip_axis else pp .Min_Ind ,
536- x_max = pp .Max_Dep if flip_axis else pp .Max_Ind ,
537- y_min = pp .Min_Ind if flip_axis else pp .Min_Dep ,
538- y_max = pp .Max_Ind if flip_axis else pp .Max_Dep ,
539- legend_location = matlab_legend_to_matplotlib (pp .Key_Position ),
540- plot_type = plot_type ,
541- plot_title = pp .Plot_Title ,
542535 )
543536
544537 # --- Interpolated, metric-aware model logic ---
@@ -800,7 +793,7 @@ def plot_to_fig(x_data,y_data,**kwargs):
800793 ax = fig .add_axes ([left , bottom , ax_w , ax_h ])
801794
802795 # widen paper if legend is outside, keeping axes fixed in physical size
803- if kwargs .get ('legend_location' ) == 'outside' :
796+ if ( kwargs .get ('legend_location' ) == 'outside' ) and ( not using_existing_figure ) :
804797 legend_expand = kwargs .get ('legend_expand' , 1.25 )
805798 old_size = fig .get_size_inches ()
806799
@@ -1339,14 +1332,13 @@ def get_plot_style(style="fds"):
13391332
13401333def matlab_legend_to_matplotlib (position ):
13411334 """
1342- Convert a MATLAB legend position string to the corresponding matplotlib location string.
1335+ Convert a MATLAB legend position string to a matplotlib-compatible location.
1336+ """
1337+ if not isinstance (position , str ):
1338+ return 'best'
13431339
1344- Parameters:
1345- position (str): MATLAB-style legend position (e.g., 'northeast', 'southwestoutside')
1340+ pos = position .strip ().lower ()
13461341
1347- Returns:
1348- str: Matplotlib-compatible legend location (e.g., 'upper right')
1349- """
13501342 mapping = {
13511343 'north' : 'upper center' ,
13521344 'south' : 'lower center' ,
@@ -1356,17 +1348,15 @@ def matlab_legend_to_matplotlib(position):
13561348 'southeast' : 'lower right' ,
13571349 'southwest' : 'lower left' ,
13581350 'northwest' : 'upper left' ,
1359- 'northeastoutside' : 'center left' , # rough equivalent
1360- 'northwestoutside' : 'center right' ,
1361- 'southeastoutside ' : 'center left ' ,
1362- 'southwestoutside' : 'center right' ,
1351+
1352+ # outside positions (MATLAB → Matplotlib approximations)
1353+ 'eastoutside ' : 'outside ' ,
1354+
13631355 'best' : 'best'
13641356 }
13651357
1366- if not isinstance (position , str ):
1367- return 'best'
1358+ return mapping .get (pos , 'best' )
13681359
1369- return mapping .get (position .strip ().lower (), 'best' )
13701360
13711361
13721362def define_plot_parameters (D , irow , lightweight = False ):
0 commit comments