数组1[1,2,3,4,5,4,2,6,6,8]
数组2[1,2,3,1,5,4,2,7,6,8]
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1,2,3,4,5,4,2,6,5,8])
y = np.array([1,2,3,4,5,4,2,6,6,8])
c = []
txt = []
for i in range(len(x)):
if x[i] == y[i]:
c.append("red")
txt.append([x[i], y[i], ""])
else:
c.append("green")
txt.append([x[i], y[i], "{},{}".format(x[i], y[i])])
colors = np.array(c)
plt.scatter(x, y, c=colors)
for i in txt:
plt.annotate(i[2],xy=(i[0],i[1]))
plt.show()
要硬上matplotlib , 就搞个散点图。 一样的红色, 不一样的绿色
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1,2,3,4,5,4,2,6,5,8])
y = np.array([1,2,3,4,5,4,2,6,6,8])
c = []
for i in range(len(x)):
if x[i] == y[i]:
c.append("red")
else:
c.append("green")
colors = np.array(c)
plt.scatter(x, y, c=colors)
plt.show()