Closed camiloramirezgo closed 1 year ago
I added the option to configure the appearance of the stats box in the plot
function. So we need to update the call to the function in the notebook, and users can play around with that. It looks something like this now:
results.plot('max_benefit_tech', cmap=cmap,
title=f'Maximum net-benefit cooking technology',
figsize=(5, 7),
labels=labels, legend=True, legend_title='Maximum benefit\ncooking technology',
legend_position=(1, 0.7),
legend_prop={'title': {'size': 10, 'weight': 'bold'}, 'size': 9},
rasterized=True, stats=True,
stats_kwargs={'extra_stats': None, 'fontsize': 10, 'stats_position': (1, 0.9), 'pad': 2, 'sep': 0, 'fontcolor': 'black', 'fontweight': 'normal',
'box_props': dict(facecolor='lightyellow', edgecolor='black', alpha=1, boxstyle="sawtooth")},
dpi=300,
save_as='map.png'
)
Producing the following:
If the user do not pass a stats_kwargs
dictionary, then default values will be used (the normal style we had).
The call to the plot_benefits_distribution
method now needs to be done as:
results.plot_distribution(type='histogram', groupby='None', cmap=cmap, labels=labels,
hh_divider=1000, y_title='Households (k)',
# groupby_kwargs=dict(scales='fixed'),
# kwargs=dict(alpha=0.8, size=0.2),
quantiles=True,
height=1.5, width=3.5, dpi=300, save_as='dist.png')
I generalized it, adding a variable
parameter for the x axis, which defaults to wealth
. I also added a groupby_kwargs
dictionary, to be able to change the parameters of the facets when grouping by a variable as urban-rural
split. Moreover, the kwargs
dictionary allows to change the style of the bars, as alpha, size of the lines and color of the lines.
It also has an extra parameter quantiles
, which if True
will draw the lines for quantiles 1 and 3 of the distribution:
The plot_cost_benefit
method now has one extra parameters legend_args
, which allows the user to change the position, direction and number of columns displayed in the legend:
results.plot_costs_benefits(labels=labels, height=1.5, width=3, dpi=300, save_as='benefits.png',
legend_args=dict(legend_position=(0.5, -0.6), legend_direction='horizontal', ncol=2))
Add parameters to the plotting functions to save the images as
dpi=300, save_as='tech_split.png'
. This now works for all plots including the map, but needs to be implemented in the notebook.