[英]Matplotlib: plotting time seconds are floats
我已經使用matplotlib創建了一些圖形。 X軸始終包含時間,Y軸始終包含給定值。
圖形創建如下:
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.set_title('Experience Graph')
ax.set_xlabel('Time')
ax.set_ylabel('Experience')
ax.plot(self.timeStorage, teamTotalXP)
ax.fill_between(self.timeStorage,0, teamTotalXP, alpha=0.5)
...
plt.xticks(rotation=20)
plt.savefig(directory + "teams_experience.svg")
plt.clf()
使用以下方式創建時間存儲:
timeStorage.append(datetime.datetime.utcfromtimestamp(replay.info.game_time))
我在2種不同的Ubuntu實現中嘗試了此方法:
Ubuntu 1:
Ubuntu 2:
可以看出,我的第二個版本具有令人討厭的浮點數(以秒為單位)。
額外的信息:
因此,我想知道是否有人知道如何解決我的問題,或者降級是唯一的解決方案。
提前致謝,
吉里爾
解決方案是使用DateFormatter。 奇怪的是,我以前不必這樣做。
查看此答案以獲取更多信息: 如何在python中使用matplolib更改日期格式
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.