python 画图

matplotlib官网

https://matplotlib.org/

在一张图中画多跳线

https://jingyan.baidu.com/article/b7001fe1db54320e7282ddfe.html

import numpy as np

import matplotlib.pyplot as plt

# 以0.2为间隔均匀采样

t = np.arange(0., 5., 0.2)

#查看t的值

print t

# 'r--':红色的需要;'bs':蓝色方块;'g^':绿色三角

plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')

plt.show()

matplotlib介绍

https://zhuanlan.zhihu.com/p/109245779

Python设置matplotlib.plot的坐标轴刻度间隔以及刻度范围

https://www.jb51.net/article/163842.htm

import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
#从pyplot导入MultipleLocator类,这个类用于设置刻度间隔
 
x_values=list(range(11))
y_values=[x**2 for x in x_values]
plt.plot(x_values,y_values,c='green')
plt.title('Squares',fontsize=24)
plt.tick_params(axis='both',which='major',labelsize=14)
plt.xlabel('Numbers',fontsize=14)
plt.ylabel('Squares',fontsize=14)
x_major_locator=MultipleLocator(1)
#把x轴的刻度间隔设置为1,并存在变量里
y_major_locator=MultipleLocator(10)
#把y轴的刻度间隔设置为10,并存在变量里
ax=plt.gca()
#ax为两条坐标轴的实例
ax.xaxis.set_major_locator(x_major_locator)
#把x轴的主刻度设置为1的倍数
ax.yaxis.set_major_locator(y_major_locator)
#把y轴的主刻度设置为10的倍数
plt.xlim(-0.5,11)
#把x轴的刻度范围设置为-0.5到11,因为0.5不满一个刻度间隔,所以数字不会显示出来,但是能看到一点空白
plt.ylim(-5,110)
#把y轴的刻度范围设置为-5到110,同理,-5不会标出来,但是能看到一点空白
plt.show()

图例

中文显示

只需加上一句

plt.rcParams['font.sans-serif'] = ['Arial Unicode MS'] 

matplotlib图例中文乱码?

https://www.zhihu.com/question/25404709/answer/309784195

图例显示方法(多种

https://www.cnblogs.com/linblogs/p/9642031.html

plt.rcParams['font.sans-serif'] = ['Arial Unicode MS'] 
tickSea=dataSea2001[indSea,0]
#plt.plot(CISea[15:-2,0],'b',ECSea[15:-2,0],'r')
#plt.xlabel('时间')
#plt.ylabel('累计值')
x_major_locator=plt.MultipleLocator(9)
#把x轴的刻度间隔设置为3,并存在变量里
ax=plt.gca()
#ax为两条坐标轴的实例
ax.xaxis.set_major_locator(x_major_locator)
#把x轴的主刻度设置为9的倍数
#plt.plot(tickSea[15:-2],CISea[15:-2,0],'b')
#plt.plot(tickSea[15:-2],CISea[15:-2,1],'b',tickSea[15:-2],ECSea[15:-2,2],'r')
plt.plot(tickSea[15:-2],CISea[15:-2,1],'b',label='sr')
plt.plot(tickSea[15:-2],ECSea[15:-2,2],'r',label='GDP')
plt.legend(['社会融资规模:累计值','GDP:现价:累计值'])
#plt.show()

绘制多个图形

subplot

https://zhuanlan.zhihu.com/p/109245779

数据可视化——次坐标

https://blog.csdn.net/fly_wt/article/details/84665696

fig,ax0=plt.subplots()
ax0i=ax0.twinx()
ax0.plot(tickV,CLvalue[:,1],'b')
ax0i.plot(tickV,ECvalue[:,0],'r')

python  作图方法介绍

https://mp.weixin.qq.com/s/d1UsJccLRyAPe9pGc16YEg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值