@@ -76,9 +76,9 @@ def _extract_plot_data(event_data: PlotEventData, q4: bool, show_error_bar: bool
7676 for j in range (len (sld )):
7777 results ["sld" ][- 1 ].append ([sld [j ][:, 0 ], sld [j ][:, 1 ]])
7878
79+ results ["sld_resample" ].append ([])
7980 if event_data .resample [i ] == 1 or event_data .modelType == "custom xy" :
8081 layers = event_data .resampledLayers [i ][0 ]
81- results ["sld_resample" ].append ([])
8282 for j in range (len (event_data .resampledLayers [i ])):
8383 layer = event_data .resampledLayers [i ][j ]
8484 if layers .shape [1 ] == 4 :
@@ -198,7 +198,7 @@ def plot_ref_sld_helper(
198198 sld_min , sld_max = confidence_intervals ["sld" ][i ][j ]
199199 sld_plot .fill_between (plot_data ["sld" ][i ][j ][0 ], sld_min , sld_max , alpha = 0.6 , color = "grey" )
200200
201- if plot_data ["sld_resample" ]:
201+ if plot_data ["sld_resample" ] and plot_data [ "sld_resample" ][ i ] :
202202 for j in range (len (plot_data ["sld_resample" ][i ])):
203203 sld_plot .plot (
204204 plot_data ["sld_resample" ][i ][j ][0 ],
@@ -544,7 +544,7 @@ def update_foreground(self, data):
544544 self .figure .axes [1 ].draw_artist (self .figure .axes [1 ].lines [i ])
545545 i += 1
546546
547- if plot_data ["sld_resample" ]:
547+ if plot_data ["sld_resample" ] and plot_data [ "sld_resample" ][ j ] :
548548 for resampled in plot_data ["sld_resample" ][j ]:
549549 self .figure .axes [1 ].lines [i ].set_data (resampled [0 ], resampled [1 ])
550550 self .figure .axes [1 ].draw_artist (self .figure .axes [1 ].lines [i ])
@@ -982,10 +982,7 @@ def plot_contour(
982982
983983
984984def panel_plot_helper (
985- plot_func : Callable ,
986- indices : list [int ],
987- fig : matplotlib .figure .Figure | None = None ,
988- progress_callback : Callable [[int , int ], None ] | None = None ,
985+ plot_func : Callable , indices : list [int ], fig : matplotlib .figure .Figure | None = None
989986) -> matplotlib .figure .Figure :
990987 """Generate a panel-based plot from a single plot function.
991988
@@ -997,9 +994,6 @@ def panel_plot_helper(
997994 The list of indices to pass into ``plot_func``.
998995 fig : matplotlib.figure.Figure, optional
999996 The figure object to use for plot.
1000- progress_callback: Union[Callable[[int, int], None], None]
1001- Callback function for providing progress during plot creation
1002- First argument is current completed sub plot and second is total number of sub plots
1003997
1004998 Returns
1005999 -------
@@ -1011,19 +1005,21 @@ def panel_plot_helper(
10111005 nrows , ncols = ceil (sqrt (nplots )), round (sqrt (nplots ))
10121006
10131007 if fig is None :
1014- fig = plt .subplots (nrows , ncols , figsize = (11 , 10 ), subplot_kw = { "visible" : False } )[0 ]
1008+ fig = plt .subplots (nrows , ncols , figsize = (11 , 10 ))[0 ]
10151009 else :
10161010 fig .clf ()
1017- fig .subplots (nrows , ncols , subplot_kw = { "visible" : False } )
1011+ fig .subplots (nrows , ncols )
10181012 axs = fig .get_axes ()
1019- for index , plot_num in enumerate (indices ):
1020- axs [index ].tick_params (which = "both" , labelsize = "medium" )
1021- axs [index ].xaxis .offsetText .set_fontsize ("small" )
1022- axs [index ].yaxis .offsetText .set_fontsize ("small" )
1023- axs [index ].set_visible (True )
1024- plot_func (axs [index ], plot_num )
1025- if progress_callback is not None :
1026- progress_callback (index , nplots )
1013+
1014+ for plot_num , index in enumerate (indices ):
1015+ axs [plot_num ].tick_params (which = "both" , labelsize = "medium" )
1016+ axs [plot_num ].xaxis .offsetText .set_fontsize ("small" )
1017+ axs [plot_num ].yaxis .offsetText .set_fontsize ("small" )
1018+ plot_func (axs [plot_num ], index )
1019+
1020+ # blank unused plots
1021+ for i in range (nplots , len (axs )):
1022+ axs [i ].set_visible (False )
10271023
10281024 fig .tight_layout ()
10291025 return fig
@@ -1040,7 +1036,6 @@ def plot_hists(
10401036 block : bool = False ,
10411037 fig : matplotlib .figure .Figure | None = None ,
10421038 return_fig : bool = False ,
1043- progress_callback : Callable [[int , int ], None ] | None = None ,
10441039 ** hist_settings ,
10451040):
10461041 """Plot marginalised posteriors for several parameters from a Bayesian analysis.
@@ -1077,9 +1072,6 @@ def plot_hists(
10771072 The figure object to use for plot.
10781073 return_fig: bool, default False
10791074 If True, return the figure as an object instead of showing it.
1080- progress_callback: Union[Callable[[int, int], None], None]
1081- Callback function for providing progress during plot creation
1082- First argument is current completed sub plot and second is total number of sub plots
10831075 hist_settings :
10841076 Settings passed to `np.histogram`. By default, the settings
10851077 passed are `bins = 25` and `density = True`.
@@ -1138,7 +1130,6 @@ def validate_dens_type(dens_type: str | None, param: str):
11381130 ),
11391131 params ,
11401132 fig ,
1141- progress_callback ,
11421133 )
11431134 if return_fig :
11441135 return fig
@@ -1153,7 +1144,6 @@ def plot_chain(
11531144 block : bool = False ,
11541145 fig : matplotlib .figure .Figure | None = None ,
11551146 return_fig : bool = False ,
1156- progress_callback : Callable [[int , int ], None ] | None = None ,
11571147):
11581148 """Plot the MCMC chain for each parameter of a Bayesian analysis.
11591149
@@ -1172,9 +1162,6 @@ def plot_chain(
11721162 The figure object to use for plot.
11731163 return_fig: bool, default False
11741164 If True, return the figure as an object instead of showing it.
1175- progress_callback: Union[Callable[[int, int], None], None]
1176- Callback function for providing progress during plot creation
1177- First argument is current completed sub plot and second is total number of sub plots
11781165
11791166 Returns
11801167 -------
@@ -1200,7 +1187,7 @@ def plot_one_chain(axes: Axes, i: int):
12001187 axes .plot (range (0 , nsimulations , skip ), chain [:, i ][0 :nsimulations :skip ])
12011188 axes .set_title (results .fitNames [i ], fontsize = "small" )
12021189
1203- fig = panel_plot_helper (plot_one_chain , params , fig , progress_callback )
1190+ fig = panel_plot_helper (plot_one_chain , params , fig = fig )
12041191 if return_fig :
12051192 return fig
12061193 plt .show (block = block )
0 commit comments