相关内容
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 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)
借助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)
多图表
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]