您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何使xticks均匀分布而不管其价值?

如何使xticks均匀分布而不管其价值?

您可以通过将变量绘制为参数化曲线的“自然”变量的函数来进行绘制。例如:

n = 12
a = np.arange(n)
x = 2**a
y = np.random.rand(n)

fig = plt.figure(1, figsize=(7,7))
ax1  = fig.add_subplot(211)
ax2  = fig.add_subplot(212)

ax1.plot(x,y)
ax1.xaxis.set_ticks(x)

ax2.plot(a, y) #we plot y as a function of a, which parametrizes x
ax2.xaxis.set_ticks(a) #set the ticks to be a
ax2.xaxis.set_ticklabels(x) # change the ticks' names to x

产生:

在此处输入图片说明

其他 2022/1/1 18:30:38 有437人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶