0

I'm having some issues in setting the ticks in my plots using matplotlib. What I need is to set the ticks inwards, so inside the figure (but the labels must stay outside), and at the same time I need to have ticks on all four boundaries. Do you know a simple way to do this?

Thanks in advance!

  • 1
    Explore the [ax.tick_params](https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.axes.Axes.tick_params.html) and perhaps [this](https://stackoverflow.com/questions/34955160/direction-of-tick-marks-in-matplotlib) SO question. – cfort Jun 11 '20 at 16:03

1 Answers1

0

Just because it can be useful for other people, I post here the simple solution I found after looking for some time in the documentation, as suggested by cfort:

ax.xaxis.set_ticks_position('both')
ax.xaxis.set_tick_params(direction='in', which='both', labelsize=16)
ax.yaxis.set_ticks_position('both')
ax.yaxis.set_tick_params(direction='in', which='both', labelsize=16)
ax.minorticks_on()

these lines of code set the tick inwards on both sides (e.g. for the x axis they are placed at top and bottom of the figure), set the label size and add the minorticks, which will point in the inward direction as well.