【问题标题】:Scatter plot with infinitesimal point size in PythonPython中具有无穷小点大小的散点图
【发布时间】:2017-08-21 16:55:02
【问题描述】:

是否可以在 python 中做散点图,在给定的比例下,点的最小尺寸为 1 个像素? IE。点不应该缩放,因为我缩放绘图并且始终具有 1 个像素的大小。

在pyplot中

plt.scatter(d3_transformed[:,0], d3_transformed[:,1], s=1)

我还是这样胖点

【问题讨论】:

    标签: python matplotlib scatter-plot


    【解决方案1】:

    您可以通过设置marker='.' 将标记更改为一个点,然后通过使用linewidths=0 删除轮廓来进一步减小其大小。请注意,markeredgewidth 不适用于 scatter

    考虑这个例子。如您所见,绘制的最后一行点 (marker='.', s=1, linewidths=0) 给出了最小的标记:

    import matplotlib.pyplot as plt
    import numpy as np
    
    fig, ax = plt.subplots(1)
    x = np.linspace(0, 10, 100)
    
    ax.scatter(x, np.ones_like(x)+0, marker='o', s=1, color='k')
    ax.scatter(x, np.ones_like(x)+1, marker='o', s=1, color='k', linewidths=0)
    ax.scatter(x, np.ones_like(x)+2, marker='.', s=1, color='k')
    ax.scatter(x, np.ones_like(x)+3, marker='.', s=1, color='k', linewidths=0)
    
    plt.show()
    

    【讨论】:

      【解决方案2】:

      在散点图中,点有marker,它是一个符号,就像圆一样,这个符号也有一个边框。我认为默认情况下边框是打开的。尝试关闭无聊,例如将其宽度设置为0。

      http://matplotlib.org/api/lines_api.html#matplotlib.lines.Line2D.set_markeredgewidth

      【讨论】:

      • 在哪里应用这个功能,对不起?
      • 您可以使用markeredgewidth(或mew)作为散点图argplt.scatter(d3_transformed[:,0], d3_transformed[:,1], s=1, markeredgewidth=0)
      • 或者你可以使用像+这样的“较小”符号来代替圆圈
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多