- 通过np.arange(0,255,1)实现x轴序列
- python不像Matlab绘制曲线时需要hold on,多个plot就直接显示在一条直线上了
- 给图像添加图例使用的是
plot(x,y1,label='y1=x')
,使用legend()
显示图例,同样,只需要显示一次就行
"""
created on Friday June 22 17:47 2018
@author: Jerry
"""
import matplotlib as mpl
mpl.rcParams['font.sans-serif']=[u'SimHei']
import numpy as np
from pylab import *
x = np.arange(0,255,1)
y1 = x
y2 = 255 - x
y3 = (100/255)*x+100
y4 = 255*(x/255)**2
plot(x,y1,label='y1=x')
plot(x,y2,label='y2=255-x')
plot(x,y3,label='y3=(100/255)*x+100')
plot(x,y4,label='255*(x/255)**2')
legend()
show()
结果展示: