import pandas as pd
import matplotlib.pyplot as plt
#设置显示的行列数
pd.set_option('display.max_rows',25000)
pd.set_option('display.max_columns',30)
#读取数据
data=pd.read_csv('wc0329.csv')
#利用groupby聚合,并排序
sku=data.groupby(['bigcato']).count().sort_values('sku')
x=sku.index
y=sku['sku']
#matplotlib包绘制散点图,颜色与y值做了映射,值越大,颜色越深
plt.scatter(x,y,c=y,cmap='Reds')
plt.xlabel('big categories')
plt.ylabel('qty')
plt.show()
#输出:
Python3 绘制简单的散点图
最新推荐文章于 2023-07-13 19:19:42 发布