I have an image that I've defined using the following:
import matplotlib as mpl
import numpy as np
import pandas as pd
d = {'ind': [15041, 15149, 15150, 15158], '1': [.0051, .0076, .0051, .0151], '2':[np.NaN, .0079, .0053, .0134],
'3':[np.NaN, .0085, .0056, .0135], '4':[np.NaN, .0088, .0058, .0111], '5':[np.NaN, .008907, .0057, .01011],
'6':[np.NaN, np.NaN, np.NaN, .0098], '7':[np.NaN, np.NaN, np.NaN, .0076], '8':[np.NaN, np.NaN, np.NaN, .0057]}
data = pd.DataFrame(data=d).set_index('ind')
eccs = mpl.colors.ListedColormap(['navy', 'firebrick', 'gold', 'darkgreen', 'darkorange', 'darkcyan', 'purple', 'saddlebrown'], N = 8)
fig = data.plot.bar(stacked = False, figsize=(6,6), width = 0.88, zorder = 3, align = 'center', cmap = eccs)
It looks like this:
How do I "autofit" the bar widths? E.g. make the width of the bar from the first grouping (15041) the same as the width of the 8 bars from the last (15158). I'd like to remove the white space from this plot in a programatic way, similar to how geom_bar()
in ggplot2 automatically changes the widths of the bars.