2016-02-29 153 views
0

我們如何繪製具有日期時間值的facetgrid,如下面的第一個示例所示。Python seaborn facetgrid x軸日期不顯示

from datetime import date, timedelta 
import pandas as pd 
import seaboarn as sns 

test = [{"date": date.today(), "categ": "test1", "value": 100}, {"date": date.today() - timedelta(days=1), "categ": "test2", "value": 200}] 

df = pd.DataFrame(test) 

第一示例使用seaborn

ax= sns.barplot("date","value", data=df) 

Example1

其次使用FacetGrid

g = sns.FacetGrid(df, row='categ') 
g.map(plt.bar, "date", "value") 

Example2實施例

回答

0

試着改變你的第二個部分:

FROM:

g.map(plt.bar, "date", "value") 

TO:

g.map(sns.barplot, "date", "value")