seaborn更适合数据源为DataFrame的数据类型
一。画柱状图
爬虫爬取的数据
柱状图的画法
'''画柱状图'''
def drawBar(data,x_label,y_label,title,savepath='results'):
if not os.path.exists(savepath):
os.mkdir(savepath)
ax=seaborn.barplot(x=x_label,y=y_label,palette='RdBu_r',data=data) #调色板palette
ax.set_title(title)
plt.show()
fig = ax.get_figure()
fig.savefig(os.path.join(savepath,title+'.png'))
def price_count(self):
# 价格统计
prices = []
for key, value in self.data.items():
if value[0]:
prices.append(value[0])
price1_count = (np.array(prices) < 3).sum()
price2_c