Matplotlib的子图subplot的使用 - 简书
更多的图可以参考:https://matplotlib.org/gallery/index.html,这里有很完善的图和代码。

散点图

  1. import matplotlib.pyplot as plt
  2. # simulating a pandas df['type'] column
  3. types = ['apple', 'orange', 'apple', 'pear', 'apple', 'orange', 'apple', 'pear']
  4. x_coords = [10, 10, 5, 4, 3, 20, 19, 21]
  5. y_coords = [21, 23, 12, 21, 10, 20, 14, 2]
  6. for i,type in enumerate(types):
  7. x = x_coords[i]
  8. y = y_coords[i]
  9. plt.scatter(x, y, marker='x', color='red')
  10. plt.text(x+0.3, y+0.3, type, fontsize=9)
  11. plt.show()

image.png