美文网首页
常用图表

常用图表

作者: 异想派 | 来源:发表于2016-10-21 19:23 被阅读12次

    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()
    

    相关文章

      网友评论

          本文标题:常用图表

          本文链接:https://www.haomeiwen.com/subject/zpdcuttx.html