直方图的绘制
# 直接绘制
reviews['province'].value_counts().head(10).plot.bar()
# 百分比图的绘制
(reviews['province'].value_counts().head(10) / len(reviews)).plot.bar()
# 一种与上述方法横坐标不同的直方图
reviews['points'].value_counts().sort_index().plot.bar()
# 统计直方图(横坐标是区间不再是单一值,为防止数据偏重,故加以小于200的限制)
reviews[reviews['price'] < 200]['price'].plot.hist()
线型图的绘制
# 普通绘制
reviews['points'].value_counts().sort_index().plot.line()
# 面积图(带有阴影的折线图)
reviews['points'].value_counts().sort_index().plot.area()
双变量的绘制
# 散点图的绘制
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有关)
wine_counts.plot.area()
# 多折线图
wine_counts.plot.line()
图的调整
# 图的尺寸调整(宽度,高度)
reviews['points'].value_counts().sort_index().plot.bar(figsize=(12, 6))
# 图的颜色调整
reviews['points'].value_counts().sort_index().plot.bar(figsize=(12, 6),color='mediumvioletred')
# 图的坐标尺寸调整
reviews['points'].value_counts().sort_index().plot.bar(figsize=(12, 6),color='mediumvioletred', fontsize=16)
# 图名
reviews['points'].value_counts().sort_index().plot.bar( figsize=(12, 6),color='mediumvioletred', fontsize=16, title='Rankings Given by Wine Magazine')
# 利用matplotlib.pyplot调整图名尺寸
ax.set_title("Rankings Given by Wine Magazine", fontsize=