![](/img/trans.png)
[英]Python matplotlib categorical data y-axis and date::time x-axis
[英]Python Matplotlib lineplot with multiple x-axis data causing common y-axis issue
Python 的新手,這是我第一次使用 Matplotlib。我正在嘗試將 plot 多個數據集放到一個線圖中,但我在讓 y 軸正確顯示方面遇到了問題。
x 軸是以秒為單位的時間。 y 軸是數值。 所有數據集都作為字典鍵:值對引入,其中值是一個列表。
顯示一個 plot 似乎工作正常(圖 1),但任何時候我添加多個數據集 - 看起來 y 軸顯示每個圖的單獨范圍(圖 2)?
我注意到人們似乎使用 numpy arrays 而不是列表,但我正在使用數據當前的格式。
這里有一個類似的問題,在 Matplotlib 中的公共 x 軸上有多個圖,帶有公共 y 軸標簽,但那個人對我看到了不同的問題。
kline_data_dict = {'time': ['14:27:00', '14:27:00', '14:27:00', '14:27:00', '14:27:02', '14:27:02', '14:27:02', '14:27:02', '14:27:04', '14:27:04'], 'open': ['20854.76000000', '20854.76000000', '20854.76000000', '20854.76000000', '20861.38000000', '20861.38000000', '20861.38000000', '20861.38000000', '20861.38000000', '20861.38000000'], 'close': ['20862.47000000', '20862.47000000', '20862.47000000', '20862.47000000', '20861.80000000', '20861.80000000', '20861.80000000', '20861.80000000', '20864.65000000', '20864.65000000'], 'high': ['20879.99000000', '20879.99000000', '20879.99000000', '20879.99000000', '20864.16000000', '20864.16000000', '20864.16000000', '20864.16000000', '20869.73000000', '20869.73000000'], 'low': ['20846.30000000', '20846.30000000', '20846.30000000', '20846.30000000', '20860.27000000', '20860.27000000', '20860.27000000', '20860.27000000', '20860.27000000', '20860.27000000']}
plt.plot(kline_data_dict['time'], kline_data_dict['low'])
plt.plot(kline_data_dict['time'], kline_data_dict['high'])
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.