常用图表

Scatter

  • 表达形式
    matplotlib.pyplot.scatter(x, y, s=20, c=None, marker='o',...)
  • 参数
    1、x/y:array_like, shape (n, ),
    input data
    2、s:scalar or array_like, shape (n, ), optional, default: 20
    size in points^2
    3、c:color, sequence, or sequence of color, optional, default: ‘b’
    c can be a single color format string, or a sequence of color specifications of length N
  • Example
import numpy as np
import matplotlib.pyplot as plt
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N) #作为序列时,数目应与x长度相同
area = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radiuses。半径在0-15之间,area为面积的平方。也可使用标量统一大小
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容