def bar_fueltype_and_country_totals(dfs, keys, figsize=(12,8)):
df = lookup(dfs, keys)
countries = df.columns.levels[0] if isinstance(df.columns, pd.MultiIndex) else df.columns
n = len(countries)
subplots = gather_nrows_ncols(n)
fig, ax = plt.subplots(*subplots, figsize=figsize)
if sum(subplots)>2:
ax_iter = ax.flat
else:
ax_iter = np.array(ax).flat
for country in countries:
ax = next(ax_iter)
df[country].plot.bar(ax=ax, sharex=True, rot=55, legend=None)
ax.ticklabel_format(axis='y', style='sci', scilimits=(-2,2))
ax.set_title(country)
fig.tight_layout(pad=0.5)
return fig, ax
评论列表
文章目录