onstove.OnStove.plot_distribution#

OnStove.plot_distribution(type: str = 'histogram', fill: str = 'max_benefit_tech', groupby: str = 'None', variable: str = 'wealth', best_mix: bool = True, hh_divider: int = 1, var_divider: int = 1, labels: dict[str, str] | None = None, cmap: dict[str, str] | None = None, x_title: str | None = None, y_title: str = 'Households', groupby_kwargs: dict | None = None, quantiles: bool = False, kwargs: dict | None = None, font_args: dict | None = None, theme_name: str = 'minimal', height: float = 1.5, width: float = 2.5, save_as: str | None = None, dpi: int = 150) matplotlib.Figure[source]#

Displays a distribution plot of the stove mix in relation to a variable.

The distribution plot will show the count of househols using each stove-type in relation to the net-benefits, benefits, costs or wealth over the study area.

Parameters:
type: str, default ‘histrogram’

The type of distribution plot to use. Available options are histrogram.

Warning

The box plot option is deprecated from version 0.1.3 to favor accurate representation of data. Use histrogram instead.

fill: str, default ‘max_benefit_tech’

The categorical variable to use for the color of the histogram bars. It is normally ‘max_benefit_tech’ as we want to show the distribution of the optimal mix of stoves selected under the cost-benefit analisys.

groupby: str, default ‘None’

Groups the results by urban/rural split. Available options are None, isurban and urban-rural.

variable: str, default ‘wealth’

Variable to use for the distribution. Available options are net_benefit, benefits, costs and wealth.

best_mix: bool, default True

Whether to plot only results for the highest net-benefit technologies, or all technologies evaluated.

hh_divider: int, default 1

Value used to scale the number of households. For example, if 1000000 is used, then the households will be shown as millions (remember to change the y_title parameters in order to reflect this as y_title=’Households (millions)’).

var_divider: int, default 1

Value used to scale the analysed value. For example, if 1000 is used, then the variable will be divided by 1000, this is useful to denote units in thousands (remember to change the x_title parameters in order to reflect this as x_title=’Costs (thousands)’).

labels: dictionary of str key-value pairs, optional

Dictionary with the keys-value pairs to use for each technology.

Example of labels dictionary#
{'Collected Traditional Biomass': 'Biomass',
'Collected Improved Biomass': 'Biomass ICS (ND)',
'Traditional Charcoal': 'Charcoal',
'Biomass Forced Draft': 'Biomass ICS (FD)',
'Pellets Forced Draft': 'Pellets ICS (FD)'}
cmap: dictionary of str key-value pairs, optional

Dictionary with the colors to use for technology.

Example of cmap dictionary#
{'Biomass ICS (ND)': '#6F4070',
'LPG': '#66C5CC',
'Biomass': '#FFB6C1',
'Biomass ICS (FD)': '#af04b3',
'Pellets ICS (FD)': '#ef02f5',
'Charcoal': '#364135',
'Charcoal ICS': '#d4bdc5',
'Biogas': '#73AF48'}
x_title: str, optional

Title of the x axis. If None is provided, then a default of Net benefit per household (USD/yr), Costs per household (USD/yr) and Relative wealth index (-) will be used depending on the evaluated variable.

y_title: str, default ‘Households’

Title of the y axis.

groupby_kwargs: dict, optional.

Dictionary of properties of the groups. You can adjust the scales making them fixed or free and, if None is used as groupby, the number of colums to split the results per category (fill). It defaults to groupby_kwargs=dict(ncol=1, scales='fixed').

quantiles: boolean, default `False`.

Boolean to indicate wheter to plot the quantile lines (for Q1 and Q3 only).

kwargs: dict, optional.

Dictionary of style arguments passed to the plotting function. The default values used are dict(binwidth=binwidth, alpha=0.8, size=0.3), where binwidth is calculated as 5% of the range of the data.

font_args: dict, optional.

Dictionary of font arguments passed to the plotting function. If None is provided, defaults to dict(size=6). For available options see the plotnine.themes.element_text object.

theme_name: str, default ‘minimal’

Theme to use for the plot. Available options are ‘minimal’ and ‘classic’ from the plotnine:generated/plotnine.themes package.

height: float, default 1.5

The heihg of the figure in inches.

width: float, default 2.5

The width of the figure in inches.

save_as: str, optional

If a string is passed, then the plot will be saved with that name and extension file in the:attr:output_directory as name.pdf, name.png, name.svg, etc.

dpi: int, default 150

The resolution of the figure in dots per inch.

Returns:
matplotlib.Figure

Figure object used to plot the distribution