我正在使用
plt. plot_date([dates[index], dates[index] timeD], [pivots[index],pivots[index]], linestyle = "-", linewidth=2, marker = " , ", )
要在圖表上畫一些線。 這曾經是有效的,但現在在做了一些升級后,顯示了一個警告:
UserWarning: marker 是由'marker'關鍵字引數和fmt字串"o"(-> marker='o')冗余定義。關鍵字引數將被優先考慮。
plt.plot_date([dates[index], dates[index] timeD], [pivots[index],pivots[index]], linestyle = "-", linewidth=2, marker = " , ", )
如果我省略marker = "," ,警告就會消失,但在行首和行尾有兩個點,我不喜歡。
我怎么做才能在不改變情節的情況下消除警告呢?
uj5u.com熱心網友回復:
plt.plot_date需要關鍵字引數fmt,這是matplotlib定義標記和線型的簡寫。
如果你沒有提供該fmt關鍵字,則會使用一個默認值。"o"
fmt來定義你的標記和線型,而不是使用marker和linestyle kwargs:
plt.plot_date([dates[index], dates[index] timeD], [pivots[index],pivots[index]],
fmt=",-", linewidth=2)
關于fmt的更多資訊,請參見plt.plot>的檔案底部的注釋。 plot;注意,fmt在plot_date和plot中的使用略有不同,因為它總是被定義在plot_date中,而它在plot中是可選的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/312381.html
標籤:
上一篇:如何獲得pandas條形圖的顏色
