Skip to content

Commit 033368e

Browse files
committed
add plot option.
1 parent 4bec792 commit 033368e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

climada/engine/impact.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,25 @@ def _exp_impact(self, exp_iimp, exposures, hazard, imp_fun, insure_flag):
226226
self.at_event += np.squeeze(np.asarray(np.sum(impact, axis=1)))
227227
self.tot_value += np.sum(exposures.value[exp_iimp])
228228

229-
def plot_eai_exposure(self, ignore_zero=True, **kwargs):
229+
def plot_eai_exposure(self, ignore_zero=True, var_name=None, **kwargs):
230230
"""Plot expected annual impact of each exposure.
231231
232232
Parameters:
233-
ignore_zero (bool): ignore zero impact values at exposures
233+
ignore_zero (bool, optional): ignore zero impact values
234+
var_name (str, optional): name in colorbar
234235
kwargs (optional): arguments for hexbin matplotlib function
235236
236237
Returns:
237238
matplotlib.figure.Figure, cartopy.mpl.geoaxes.GeoAxesSubplot
238239
"""
239240
title = 'Expected annual impact'
240-
col_name = 'Impact ' + self.unit
241+
if var_name is None:
242+
var_name = 'Impact (' + self.unit + ')'
241243
if ignore_zero:
242244
pos_vals = self.eai_exp > 0
243245
else:
244246
pos_vals = np.ones((self.eai_exp.size,), dtype=bool)
245247
if 'reduce_C_function' not in kwargs:
246248
kwargs['reduce_C_function'] = np.sum
247249
return plot.geo_bin_from_array(self.eai_exp[pos_vals], \
248-
self.coord_exp[pos_vals], col_name, title, **kwargs)
250+
self.coord_exp[pos_vals], var_name, title, **kwargs)

0 commit comments

Comments
 (0)