Skip to content
Advertisement

how to show tick labels on top of matplotlib plot?

In matplotlib what is the way to have tick labels both at the bottom and in the top x axis? I have searched a lot and still can’t find how to do it.

Advertisement

Answer

Sorry, I lied in the comments. You can do this easily (but it seems to be badly documented)

fig, ax = plt.subplots(1, 1)
ax.xaxis.set_tick_params(labeltop='on')

output

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement