Reputation: 397
I am currently working on a barplot which looks like this:
In order to provide more clarity, I would like to add a vertical line that should point out the separation between the x values. I've drawn an example here:
In order to draw the diagram, I am using the plot function from pandas on the corresponding dataframe:
produced_items.plot(kind='bar', legend=True,title="Produced Items - Optimal solution",xlabel="Months",ylabel='Amount',rot=1,figsize=(15,5),width=0.8)
I hoped to find a parameter in matplotlib, that yields the desired behavior, but I didn't find anything, that could help. Another solution that comes in my mind is to plot a vertical line between each x-value but i wonder if there is a built-in way to accomplish this?
Upvotes: 0
Views: 571
Reputation: 150735
Let's try modifying the minor ticks:
from matplotlib.ticker import MultipleLocator
ax = df.plot.bar()
# set the minor ticks
ax.xaxis.set_minor_locator(MultipleLocator(0.5))
# play with the parameters to get your desired output
ax.tick_params(which='minor', length=15, direction='in')
Output:
Upvotes: 1