Skip to content Skip to sidebar Skip to footer

How To Put Variable Length Tick Labels Inside The Plot Canvas In Matplotlib?

I want to turn this: into something resembling this: All of the instructions I have come across just apply an offset to the label position and therefore only work if the labels are

Solution 1:

Adding the following two lines to your code

ax.tick_params(axis="y", direction="in", pad=-10)
plt.setp(ax.get_yticklabels(),ha="left")

will result in the following plot

enter image description here

Post a Comment for "How To Put Variable Length Tick Labels Inside The Plot Canvas In Matplotlib?"