import matplotlib.pyplot as plt
x = range(0, 5)
y1 = [3, 6, 6, 8, 9]
y2 = [2, 5, 5, 7, 8]
y3 = [6, 6, 8, 8, 1]
p1 = plt.scatter(x, y1, marker='x', color='g', label='1', s=30)
p2 = plt.scatter(x, y2, marker='+', color='r', label='2', s=30)
p3 = plt.scatter(x, y3, marker='*', color='c', label='3', s=30)
plt.title('Scatter')
plt.legend(loc='upper right')
plt.xticks(x)
plt.show()
运行结果
我也遇到同样的问题了,你在头上加一个import turtle,然后再在最后一行加一个turtle.done(),别问我为什么,我也不知道。