使用python画图实例

import numpy as np
import matplotlib.pyplot as plt

# cc= np.linspace(0,2,100)
# plt.rcParams['font.sans-serif'] = ['SimHei']
# plt.plot(cc,cc,label='linear')
# plt.plot(cc,cc**2,label='两倍')
# plt.plot(cc,cc**3,label='三倍')
# plt.xlabel('x label')
# plt.ylabel('y label')
# plt.title("折线图")
# plt.legend()
# plt.show()

x = [-1.0000,-0.8000,-0.6000,-0.4000,-0.2000,0,0.2000,0.4000,0.6000,0.8000,1.0000]
x1 = [280,280,280,281,281,281,281,281,282,282,282]
x2 = [280.0000,280.2000,280.4000,280.6000,280.8000,281.0000,281.2000,281.4000,281.6000,281.8000,282.0000]

# x3 = x2 - x1
x3 = list(map(lambda x: x[0]-x[1], zip(x2, x1)))

x5 = [279.967408,280.183409,280.402330,280.524780,280.724120,280.924095,281.134822,281.369550,281.588580,281.797682,282.026252]
# x6 = x5 - x2
x6 = list(map(lambda x: x[0]-x[1], zip(x5, x2)))
plt.plot(x,x3,label ='classical (SAD/SSD/NCC/PCA)')
plt.plot(x,x6,label ='our algorithm')
plt.xlabel('Real shift/ pixel')
plt.ylabel('Calculate shift error/ pixel')
plt.grid()  # 生成网格
plt.legend()
plt.show()

 

你可能感兴趣的:(代码)