【发布时间】:2020-07-22 03:51:32
【问题描述】:
enter image description here如何在所有 x 和 y 轴的散点图中获取规则间隔。check the x and y axes of the graph how to end these congestion and put ticks in regular intervals
【问题讨论】:
标签: python matplotlib scatter-plot scatter
enter image description here如何在所有 x 和 y 轴的散点图中获取规则间隔。check the x and y axes of the graph how to end these congestion and put ticks in regular intervals
【问题讨论】:
标签: python matplotlib scatter-plot scatter
试试
plot.xticks(ticks=np.arange(min_x,max_x,step_x), labels=np.arange(min_x,max_x,step_x))
【讨论】:
由于你没有提供很多信息,这里是一个一般的答案*:
使用 numpy 用你的刻度创建一个数组:
x_ticks = np.arange(min_value, max_value + interval, interval)
因此,您可以使用数据的最小值、最大值和所需的间隔。您还可以自动确定所需的时间间隔。假设您只想在最大值之前显示 10:
interval = (max_value - min_value) / 10
对于 min=0 和 max=20,这意味着您将在 0、2、4、6、8、10、12、14、16、18、20 处有一个刻度
然后简单地设置 xticks:
plt.xticks(x_ticks)
这里有一些显示功能的示例代码:
import numpy as np
min_ = 0
max_ = 20
count = 10
distance = max_ - min_
interval = distance / count
array = np.arange(min_, max_ + interval, interval)
print(array)
print(len(array))
【讨论】: