代码示例

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

plt.figure()
plt.scatter(x, y)
plt.savefig("f.png")

绘制效果

Python编程:matplotlib绘制散点图_代码示例