相关内容
Matplotlib可视化练习
Pandas 数据可视化总结
柱状图
reviews['points'].value_counts().sort_index().plot.bar()
散点图
reviews[reviews['price'] < 100].sample(100).plot.scatter(x='price', y='points')
![](https://file.jishuzhan.net/article/1795660343859482625/79e31ee1442e733009afa41eec5617ca.webp)
蜂窝图
reviews[reviews['price'] < 100].plot.hexbin(x='price', y='points', gridsize=15)
![](https://file.jishuzhan.net/article/1795660343859482625/16d408f086497e34e800f534f60cfb53.webp)
大量重复的点可以用这种图表示
柱状图-叠加模式
![](https://file.jishuzhan.net/article/1795660343859482625/7007e6517ce41abd924d2c9630b73cc3.webp)
wine_counts.plot.bar(stacked=True)
![](https://file.jishuzhan.net/article/1795660343859482625/9ea38a66137b2d48095de83bf3d4802b.webp)
面积模式
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 plt
ax = 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)
![](https://file.jishuzhan.net/article/1795660343859482625/e41d0dd67f32c93d5a5924a6d5d372b6.webp)
借助Seaborn-去除边框
import matplotlib.pyplot as plt
import seaborn as sns
ax = 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)
![](https://file.jishuzhan.net/article/1795660343859482625/68d8beb89cb66a812b7a8ad0f2a53580.webp)
多图表
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]
![](https://file.jishuzhan.net/article/1795660343859482625/d108c499955da76d57a619dcb393294b.webp)