
正文
matplotlib和numpy 学习笔记
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
1. 在二维坐标系中画一个曲线
import matplotlib.pyplot as plt #data len=400, store int value
data = [] #set x,y轴坐标的范围
plt.axis([0, max(data), 0, 400]) #set value of the points
plt.plot(data, range(400), 'r-') #反转Y坐标轴方向
plt.gca().invert_yaxis() #设置x,y轴名称
plt.ylabel('line')
plt.xlabel('greySum') plt.show()
2. Log transformation
#!/usr/bin/python
import math
import matplotlib.pyplot as plt
import numpy as np plt.figure(figsize=(,), facecolor='white') x = np.arange(0.0, 1.0, 0.001) y=[ t for t in x]
plt.plot(x,y) v =
c = / math.log(v+)
y=[c * math.log(v*t+) for t in x]
plt.plot(x,y) v =
c = / math.log(v+)
y=[c * math.log(v*t+) for t in x]
plt.plot(x,y) plt.ylabel('Output intensity level, s')
plt.xlabel('Input intensity level, r') plt.legend(['y = x', 'y = c*log(x+1)', 'y = c*log(vx+1)'], loc='lower right') plt.show()








