2016-06-09 39 views
0

我想使用熊貓來使用ggplot主題進行打印。奇怪的使用ggplot主題的熊貓折線圖

這裏是我的樣本數據框:

seasonname Core-no season Fall/Winter Spring/Summer Summery Core True Summer 
date_utc                  
2015-06-01  199.7825 111.1363  180.3559  166.6217  66.3297 
2015-06-02  201.9999 111.9228  158.2303  153.7611  54.7868 
2015-06-03  169.8468 108.4291  137.1497  118.4648  55.1780 
2015-06-04  164.2676 108.7186  160.1299  140.5675  46.6883 
2015-06-05  144.8806  71.8517  113.8878  111.8050  31.0500 
2015-06-06  122.1885  76.7588  111.0260  92.0495  26.9652 
2015-06-07  79.8287  32.7678  41.0086  54.5739  19.5470 
2015-06-08  193.2663 125.5355  172.7237  145.4507  47.1553 
2015-06-09  175.1136  89.9360  164.2935  144.5485  52.4961 
2015-06-10  167.5729  88.9686  125.5094  153.6020  46.3585 

當我使用正常的大熊貓主題df['2015-06':].plot(figsize=(12,10))繪製它,我得到:

enter image description here

然而,當我嘗試ggplot主題,pd.options.display.mpl_style = 'default' ,我得到這個:

enter image description here

(注意:沒有軸)

它看起來像一個錯誤,但我有什麼做錯了嗎?當我刪除figsize參數時,問題仍然存在。 (熊貓版本0.18.0開始,matplotlib版本1.4.2)

+0

你爲什麼不試試這個,看看:>>>'進口matplotlib.pyplot作爲plt' >>>'plt.style.use( 'ggplot')'。有什麼改進嗎? –

+1

@NickilMaveli,就是這樣!請轉貼爲答案,我可以將其標記爲正確。 –

回答

1

要使用ggplot風格自定義圖表,你可以這樣做:

>>> import matplotlib.pyplot as plt 
>>> plt.style.use('ggplot') 

要恢復到默認的風格,你可以再做:

>>> matplotlib.style.use('default') 
+0

而根據熊貓核心開發者的說法,'pd.options.display.mpl_style ='default''已被棄用。 –