用Python畫圖時,有時候畫圖結果存儲在內存中不顯示,如下圖
import seaborn as sns
subset = tz_counts[:10]
sns.barplot(y=subset.index, x=subset.values)
<matplotlib.axes._subplots.AxesSubplot at 0x2bfcb791390>
加上命令 plt.show(),圖就能顯示,如圖:
但是,每次都這麼輸入比較麻煩,如果在Jupter中,可以使用魔法函數 %matplotlib inline,這樣就設置好了。
如果是在IPython中(如Canopy),則魔法函數稍有不同,爲%matplotlib