Rotate axis text in python matplotlib

前端 未结 13 1056
暗喜
暗喜 2020-11-22 14:50

I can\'t figure out how to rotate the text on the X Axis. Its a time stamp, so as the number of samples increase, they get closer and closer until they overlap. I\'d like

13条回答
  •  [愿得一人]
    2020-11-22 15:31

    If you want to apply rotation on the axes object, the easiest way is using tick_params. For example.

    ax.tick_params(axis='x', labelrotation=90)
    

    Matplotlib documentation reference here.

    This is useful when you have an array of axes as returned by plt.subplots, and it is more convenient than using set_xticks because in that case you need to also set the tick labels, and also more convenient that those that iterate over the ticks (for obvious reasons)

提交回复
热议问题