加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python 图表

发布时间:2020-12-20 10:39:48 所属栏目: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‘,i

#图表

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()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读