1
我有以下pandas
數據框:爲什麼seaborn在facet網格中反覆渲染同一個圖形?
Degree Entry_Year Graduations Non_Graduations Graduation_Rate
0 AUDIT 2007 0.0 1.0 0.000000
1 AUDIT 2008 0.0 7.0 0.000000
2 AUDIT 2009 0.0 4.0 0.000000
3 AUDIT 2015 0.0 1.0 0.000000
4 CERT 2009 1.0 1.0 50.000000
5 CERT 2010 4.0 6.0 40.000000
6 CERT 2011 2.0 5.0 28.571429
7 CERT 2012 1.0 6.0 14.285714
8 CERT 2013 3.0 5.0 37.500000
9 CERT 2014 5.0 7.0 41.666667
10 CERT 2015 2.0 5.0 28.571429
11 CERT 2016 0.0 4.0 0.000000
12 CERT 2017 0.0 1.0 0.000000
13 COM 2007 0.0 15.0 0.000000
14 COM 2008 0.0 16.0 0.000000
15 COM 2009 0.0 7.0 0.000000
16 CR 2012 0.0 2.0 0.000000
17 DMIN 2007 2.0 3.0 40.000000
18 MA 2007 3.0 8.0 27.272727
19 MA 2008 3.0 4.0 42.857143
20 MA 2009 1.0 8.0 11.111111
21 MA 2010 4.0 3.0 57.142857
22 MA 2011 2.0 8.0 20.000000
23 MA 2012 8.0 10.0 44.444444
24 MA 2013 1.0 0.0 100.000000
25 MA 2014 0.0 2.0 0.000000
26 MA 2015 1.0 2.0 33.333333
27 MAPSC 2010 8.0 2.0 80.000000
28 MAPSC 2011 9.0 10.0 47.368421
29 MAPSC 2012 5.0 9.0 35.714286
.. ... ... ... ... ...
61 MTS 2008 2.0 4.0 33.333333
62 MTS 2009 4.0 5.0 44.444444
63 MTS 2010 5.0 7.0 41.666667
64 MTS 2011 1.0 5.0 16.666667
65 MTS 2012 4.0 5.0 44.444444
66 MTS 2013 8.0 8.0 50.000000
67 MTS 2014 1.0 5.0 16.666667
68 MTS 2015 5.0 19.0 20.833333
69 MTS 2016 0.0 19.0 0.000000
70 MTS 2017 0.0 6.0 0.000000
當我運行下面的代碼繪製該數據作爲小網格,但是,電網只打印在同一張圖一遍又一遍。這裏是我使用的代碼:
import seaborn as sns
from matplotlib import pyplot as plt
sns.set(font_scale=1)
plot = sns.FacetGrid(df, col='Degree', col_wrap=6, despine=True)
plot = plot.map(sns.barplot, x='Entry_Year', y='Graduation_Rate', data=df, ci=None)
plot.set_xticklabels(rotation=45)
plot.fig.tight_layout(w_pad=1)
plt.show(plot)
這裏是結果我得到:
有誰知道爲什麼seaborn不使用Degree
柱構造不同地塊每個面? (我即將開始在我的通勤中,但將在一個小時左右再回來。)
輝煌!太感謝了! – tester65741