相關內容
Matplotlib可視化練習
Pandas 數據可視化總結
柱狀圖
reviews['points'].value_counts().sort_index().plot.bar()
散點圖
reviews[reviews['price'] < 100].sample(100).plot.scatter(x='price', y='points')
蜂窩圖
reviews[reviews['price'] < 100].plot.hexbin(x='price', y='points', gridsize=15)
大量重復的點可以用這種圖表示
柱狀圖-疊加模式
wine_counts.plot.bar(stacked=True)
面積模式
wine_counts.plot.area()
折線模式
wine_counts.plot.line()
美化
設置圖的大小,字體大小,顏色,標題
reviews['points'].value_counts().sort_index().plot.bar(figsize=(12, 6),color='mediumvioletred',fontsize=16,title='Rankings Given by Wine Magazine',
)
借助Matplotlib
import matplotlib.pyplot as pltax = reviews['points'].value_counts().sort_index().plot.bar(figsize=(12, 6),color='mediumvioletred',fontsize=16
)
ax.set_title("Rankings Given by Wine Magazine", fontsize=20)
借助Seaborn-去除邊框
import matplotlib.pyplot as plt
import seaborn as snsax = reviews['points'].value_counts().sort_index().plot.bar(figsize=(12, 6),color='mediumvioletred',fontsize=16
)
ax.set_title("Rankings Given by Wine Magazine", fontsize=20)
sns.despine(bottom=True, left=True)
多圖表
matplotlib
fig, axarr = plt.subplots(2, 2, figsize=(12, 8))reviews['points'].value_counts().sort_index().plot.bar(ax=axarr[0][0]
)reviews['province'].value_counts().head(20).plot.bar(ax=axarr[1][1]