I am making a stacked bar plot using:
DataFrame.plot(kind='bar',stacked=True)
I want to control width of bars so that the bars are connected to each other like a histogram.
I've looked through the documentation but to no avail - any suggestions? Is it possible to do it this way?
The space between bars can be added by using rwidth parameter inside the “plt. hist()” function. This value specifies the width of the bar with respect to its default width and the value of rwidth cannot be greater than 1.
For anyone coming across this question:
Since pandas 0.14, plotting with bars has a 'width' command: https://github.com/pydata/pandas/pull/6644
The example above can now be solved simply by using
df.plot(kind='bar', stacked=True, width=1)
See pandas.DataFrame.plot.bar
or pandas.DataFrame.plot
with kind='bar'
.
When changing the width of the bars, it might also be appropriate to change the figure size by specifying the figsize=
parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With