Skip to content

Commit

Permalink
allow multiple plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmid Timo committed Oct 30, 2023
1 parent fb51621 commit 1d4b774
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
13 changes: 9 additions & 4 deletions climada/util/calibrate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@ def plot_impf_variability(
params_within_range = p_space_df.loc[p_space_df['Cost Function'] <=
max_cost_func_val,params]

# Initialize figure
_,ax = plt.subplots()

# Plot defaults
color = plot_impf_kws.pop('color','tab:blue')
lw = plot_impf_kws.pop('lw',2)

Check warning on line 202 in climada/util/calibrate/base.py

View check run for this annotation

Jenkins - WCR / Pylint

invalid-name

LOW: Variable name "lw" doesn't conform to '(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$' pattern
Raw output
Used when the name doesn't match the regular expression associated to its type(constant, variable, class...).
Expand All @@ -208,8 +205,12 @@ def plot_impf_variability(

#get number of impact functions and create a plot for each
n_impf = len(self.impf_set.get_func(haz_type=haz_type))
axes=[]

for impf_idx in range(n_impf):

_,ax = plt.subplots()

Check warning on line 212 in climada/util/calibrate/base.py

View check run for this annotation

Jenkins - WCR / Pylint

invalid-name

LOW: Variable name "ax" doesn't conform to '(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$' pattern
Raw output
Used when the name doesn't match the regular expression associated to its type(constant, variable, class...).

#Plot best-fit impact function
best_impf = self.impf_set.get_func(haz_type=haz_type)[impf_idx]
ax.plot(best_impf.intensity,best_impf.mdd*best_impf.paa*100,
Expand Down Expand Up @@ -246,8 +247,12 @@ def plot_impf_variability(
ylabel="Mean Damage Ratio (MDR) in %",
xlim=(min(best_impf.intensity),max(best_impf.intensity)))
ax.legend()
axes.append(ax)

return ax
if n_impf > 1:

Check warning on line 252 in climada/util/calibrate/base.py

View check run for this annotation

Jenkins - WCR / Pylint

no-else-return

LOW: Unnecessary "else" after "return"
Raw output
Used in order to highlight an unnecessary block of code following an ifcontaining a return statement. As such, it will warn when it encounters anelse following a chain of ifs, all of them containing a return statement.
return axes
else:
return ax


def plot_at_event(
Expand Down
Loading

0 comments on commit 1d4b774

Please sign in to comment.