簡體   English   中英

用插值繪制兩個不同長度的列表

[英]Plotting two lists with different lengths with interpolation

我需要相互繪制兩個數字列表,但是我需要擴展兩者的范圍。

第一個列表包含事物發生的時間(我正在模擬)。 第二個包含累積頻率。 兩者的一個示例是:

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軸(numvber_of_times)的范圍為0-100的情況下相互繪制這些圖形,但要確保累積頻率仍然匹配?

目前我正在使用

plt.plot(num.keys(), cumsum)
plt.show()

但這看起來並不好。

您當前正在嘗試針對列表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()

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM