python 图表

#图表

import matplotlib.pyplot as plt

fig,ax=plt.subplots(2,2)
ax[0,1].plot(x,y,‘r--*‘,label=‘sin‘)
ax[0,1].legend(loc=‘upper right‘)
ax[0,1].grid()
fig.savefig(‘fig.png‘)

 

import pandas as pd

df=pd.read_csv(‘./data/data2.csv‘,index_col=‘产品编码‘,encoding=‘gbk‘)
df.head()

y=df[‘供应商进货价‘].values

x=df.index.values

#创建折线图
from pylab import mpl
mpl.rcParams[‘font.sans-serif‘]=[‘simhei‘]
fig,ax=plt.subplots()
ax.plot(x,‘r‘)
ax.set(title=‘年度price趋势图‘,xlabel=‘年度‘,ylabel=‘价格‘)
# plt.title(‘年度price趋势图‘)
plt.show()

#创建柱线图
from pylab import mpl
mpl.rcParams[‘font.sans-serif‘]=[‘simhei‘]
fig,ax=plt.subplots()
ax.bar(x,0.5,color=‘green‘)
ax.set(title=‘年度price趋势图‘,ylabel=‘价格‘)
# plt.title(‘年度price趋势图‘)
plt.show()

#水平柱形图

from pylab import mplmpl.rcParams[‘font.sans-serif‘]=[‘simhei‘]fig,ax=plt.subplots()ax.barh(x,color=‘green‘)ax.set(title=‘年度price趋势图‘,ylabel=‘价格‘)# plt.title(‘年度price趋势图‘)plt.show()

相关文章

功能概要:(目前已实现功能)公共展示部分:1.网站首页展示...
大体上把Python中的数据类型分为如下几类: Number(数字) ...
开发之前第一步,就是构造整个的项目结构。这就好比作一幅画...
源码编译方式安装Apache首先下载Apache源码压缩包,地址为ht...
前面说完了此项目的创建及数据模型设计的过程。如果未看过,...
python中常用的写爬虫的库有urllib2、requests,对于大多数比...