The
CodePudding user response:
In a matplotlib bar chart, the x
values are treated as categorical data, so matplotlib always plots it along range(0, ...)
and relabels the ticks with the x
values.
To scale the bar distances,
Details
Generate the xfill
as [1, 1.01, 1.02, ...]
. I've tried to make this portable by extracting the max number of decimals from x
, but float precision is always tricky so this may need to be tweaked:
start = np.floor(df.x.min())
stop = np.ceil(df.x.max())
decimals = df.x.astype(str).str.split('.').str[-1].str.len().max()
step = 10.0 ** -decimals
xfill = np.round(np.arange(start, stop, step), decimals)