@@ -259,7 +259,30 @@ def plot_shiny(
259259 hazard_plot_kwargs : Mapping [str , Any ] | None = None ,
260260 legend : bool = True ,
261261 ):
262- """Plot all impact functions with appropriate color coding and event data"""
262+ """Plot all impact functions with appropriate color coding and event data
263+
264+ Parameters
265+ ----------
266+ impact_func_creator : Callable
267+ A function taking parameters and returning an
268+ :py:class:`~climada.entity.impact_funcs.base.ImpactFuncSet`.
269+ haz_type : str
270+ The hazard type of the impact function to plot.
271+ impf_id : int
272+ The ID of the impact function to plot.
273+ inp : Input, optional
274+ The input object used for the calibration. If provided, a histogram of the
275+ hazard intensity will be drawn behin the impact functions.
276+ impf_plot_kwargs
277+ Keyword arguments for the function plotting the impact functions.
278+ hazard_plot_kwargs
279+ Keyword arguments for the function plotting the hazard intensity histogram.
280+ legend : bool
281+ Whether to create a legend or not. The legend may become cluttered for
282+ results of
283+ :py:class:`~climada.util.calibrate.ensemble.AverageEnsembleOptimizer`,
284+ therefore it is advisable to disable it in these cases.
285+ """
263286 # Store data to plot
264287 data_plt = []
265288 for _ , row in self .data .iterrows ():
@@ -402,7 +425,7 @@ def plot_category(
402425 "Cannot find a unique impact function for haz_type: "
403426 f"{ haz_type } , impf_id: { impf_id } "
404427 )
405- label = f"{ sel_category } , n= { cat_idx .sum ()} " if i == 0 else None
428+ label = f"{ sel_category } , { cat_idx .sum ()} " if i == 0 else None
406429 ax .plot (
407430 impf .intensity ,
408431 impf .paa * impf .mdd ,
@@ -412,11 +435,18 @@ def plot_category(
412435 )
413436
414437 ax .legend (
415- title = category , bbox_to_anchor = (1.05 , 1 ), loc = "upper left" , frameon = False
438+ title = f"{ category } , count" ,
439+ bbox_to_anchor = (1.05 , 1 ),
440+ loc = "upper left" ,
441+ frameon = False ,
442+ borderaxespad = 0 ,
443+ borderpad = 0 ,
416444 )
417445 # Cosmetics
418446 ax .set_xlabel (f"Intensity [{ impf .intensity_unit } ]" )
419447 ax .set_ylabel ("Impact" )
448+ ax .yaxis .set_major_formatter (mticker .PercentFormatter (xmax = 1 ))
449+ ax .set_ylim (0 , 1 )
420450 return ax
421451
422452
0 commit comments