How can I move a tick label only(without moving corresponding tick)?

前端 未结 3 1906
暖寄归人
暖寄归人 2021-01-11 10:31

I\'m using matplotlib to generate a diagram, and I use set_ticks and set_ticklabels to mark out several important values on the x-axis. But some of

3条回答
  •  旧巷少年郎
    2021-01-11 10:50

    From your comment "..mark out several important values on the x-axis" I think you shouldn't be changing the xticks and labels, but rather add vertical lines with appropriate annotation.

    This means the grid over which your data remains regular and allows you to colourise important points, you could also add the numeric values as well fairly easily.

    Example

    import pylab as py
    
    # Plot a sinc function
    delta=2.0
    x=py.linspace(-10,10,100)
    y=py.sinc(x-delta)
    
    # Mark delta
    py.axvline(delta,ls="--",color="r")
    py.annotate(r"$\delta$",xy=(delta+0.2,-0.2),color="r",size=15)
    py.plot(x,y) 
    

    Simple sinc and annotation

提交回复
热议问题