plt.scatter

plt.scatter((x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, hold=None, data=None, **kwargs))

官方手册 参数手册

绘制散点图
A scatter plot of y vs. x with varying marker size and/or color.

参数详解

  • x,y:横纵坐标的点
  • s:int,点的大小,default=‘b’
  • marker:点的形状,default=‘o’
1
2
3
4
5
6
7
8
# 绘制一个红色,倒三角的散点图
import numpy as np
import matplotlib.pyplot as plt

x = np.array([1, 2, 3, 4, 5])
y = np.array([5, 4, 3, 2, 1])
plt.scatter(x, y, s=100, c='r', marker='v')
plt.show()