Skip to content Skip to sidebar Skip to footer

Matplotlib: How To Create Vertical Lines Between X-values On Barplot?

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

Solution 1:

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:

enter image description here

Post a Comment for "Matplotlib: How To Create Vertical Lines Between X-values On Barplot?"