用插值法绘制两个不同长度的列表

2024-04-25 21:37:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要画出两个数字的对照表,但我需要扩大两者的范围。在

第一个列表包含事件发生的时间(我正在模拟)。第二个包含累积频率。两者的一个例子是:

number_of_times = [77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90]
cumsum = [0.01, 0.02, 0.03, 0.04, 0.09, 0.16, 0.3, 0.46, 0.74, 0.89, 0.95, 0.99, 1.0]

当x轴(number_of_times)的范围为0-100,但要确保累积频率仍然匹配,我该如何绘制这些曲线呢?在

目前我正在使用

^{pr2}$

但这看起来不太好。在


Tags: ofnumber列表时间绘制事件数字曲线
1条回答
网友
1楼 · 发布于 2024-04-25 21:37:32

您当前正试图根据列表cumsum绘制字典num的键。只需向plot方法提供两个列表作为参数,并使用xlim设置x限制。在

number_of_times = [77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90]
cumsum = [0.01, 0.02, 0.03, 0.04, 0.09, 0.16, 0.3, 0.46, 0.74, 0.89, 0.95, 0.99, 1.0]

plt.plot(number_of_times, cumsum)
plt.xlim(0, 100)

plt.show()

enter image description here

相关问题 更多 >

    热门问题