简体   繁体   English

如何在 matplotlib 中标记空间刻度线并自定义网格线

[英]How to mark spacial tick mark in matplotlib and custom the gridlines

My x-axis data starts from 100 to 1000 in step of 200 .我的 x 轴数据从100 to 1000 in step of 200 I want the x-axis tick marks as我想要 x 轴刻度线为

100 200 400 600 800 1000.

Is there workaround to add the 100 at the start of x-axis?是否有解决方法可以在 x 轴的开头添加100

import numpy as np
import matplotlib.pyplot as plt

x=np.arange(100,1001,20)
fig,ax=plt.subplots()
ax.plot(x,x)

#create tick positions
tp=np.arange(0,1001,200)
tp[0]=100

ax.xaxis.set_ticks(tp)
fig.show()

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM