adding extra axis ticks using matplotlib

前端 未结 2 1849
Happy的楠姐
Happy的楠姐 2021-01-31 02:12

I have a simple plot code as

plt.plot(x,y)
plt.show()

I want to add some extra ticks on the x-axis in addition to the current ones, let\'s say

2条回答
  •  孤城傲影
    2021-01-31 02:41

    Yes, you can try something like:

    plt.xticks(list(plt.xticks()[0]) + extraticks)
    

    The function to use is xticks(). When called without arguments, it returns the current ticks. Calling it with arguments, you can set the tick positions and, optionally, labels.

提交回复
热议问题