tick label positions for matplotlib 3D plot

前端 未结 3 2090
说谎
说谎 2021-01-02 10:04

I am trying to work out how to set/correct the position of tick labels for a 3D matplotlib plot. Tick labels do not align with the ticks. The issue seems to be especially pr

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-02 10:23

    They do align, but with the horizontal position centered at the tick. Because of the 3D view this makes them appear a bit below where you would expect them to be. The effect is not related to the amount of ticks but to the width.

    Specifically setting the alignment will help. Try adding:

    ax.set_yticklabels(labels,rotation=-15, va='center', ha='left')
    

    Play around a bit with the different alignments to see which you prefer, i think you're after ha='left'.

    Reducing the padding, distance from the tick, might also help.

    enter image description here

提交回复
热议问题