gpt4 book ai didi

python - 情节 : Too many ticks on X axe

转载 作者:太空狗 更新时间:2023-10-29 20:30:30 31 4
gpt4 key购买 nike

第一个加载的绘图在 X 轴上有太多刻度(参见 image01)。

enter image description here

如果我在 X 轴上使用缩放操作,绘图现在已加载完毕。

enter image description here

你能给我一些建议,我可以在哪里搜索,因为 Plot 构造函数参数看起来不错。

date_range = (735599.0, 735745.0)
x = (735610.5, 735647.0, 735647.5, 735648.5, 735669.0, 735699.0, 735701.5, 735702.5, 735709.5, 735725.5, 735728.5, 735735.5, 735736.0)
y = (227891.25361545716, 205090.4880046467, 208352.59317388065, 175462.99296699322, 98209.836461969651, 275063.37219361769, 219456.93600708069, 230731.12613806152, 209043.19805037521, 218297.51486296533, 208036.88967207001, 206311.71988471842, 216036.56824433553)
y0 = 218206.79192
x_after = (735610.5, 735647.0, 735647.5, 735701.5, 735702.5, 735709.5, 735725.5, 735728.5, 735735.5, 735736.0)
y_after = (227891.25361545716, 205090.4880046467, 208352.59317388065, 219456.93600708069, 230731.12613806152, 209043.19805037521, 218297.51486296533, 208036.88967207001, 206311.71988471842, 216036.56824433553)
linex = -39.1175584541
liney = 28993493.5251

ax.plot_date(x, numpy.array(y) / y0, color='r', xdate=True, marker='x')
ax.plot_date(x_after, numpy.array(y_after) / y0, color='r', xdate=True)
ax.set_xlim(date_range)
steps = list(ax.get_xlim())
steps.append(steps[-1] + 2)
steps = [steps[0] - 2] + steps
ax.plot(steps, numpy.array([linex * a + liney for a in steps]) / y0, color='b')

感谢您的帮助。曼纽尔

最佳答案

如果你有太多的xtick labels,太多以至于它们在图上都被拼凑在一起,你可以使用pyplot.xticks来减少它们。 .参数是标签应用的点、标签本身和可选的旋转。

import numpy as np
import matplotlib.pyplot as plt
y = np.arange(10000)
ticks = y - 5000
plt.plot(y)
k = 1000
ys = y[::k]
ys = np.append(ys, y[-1])
labels = ticks[::k]
labels = np.append(labels, ticks[-1])
plt.xticks(ys,labels, rotation='vertical')
plt.show()
plt.close()

enter image description here

关于python - 情节 : Too many ticks on X axe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31293974/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com