【问题标题】:Matplotlib Plot Dashed CirclesMatplotlib 绘制虚线圆圈
【发布时间】:2016-12-12 17:31:31
【问题描述】:

鉴于以下情况:

import matplotlib.pyplot as plt 
import numpy as np 

x = np.random.randn(60) 
y = np.random.randn(60)
x2 = np.random.randn(60)
y2 = np.random.randn(60)

plt.scatter(x, y, s=80, facecolors='none', edgecolors='r')
plt.scatter(x2, y2, s=80, facecolors='none', edgecolors='r')
plt.show()

如何仅针对 x 2 和 y2 用虚线圆圈(每个圆圈的轮廓用虚线而不是实线)绘制相同的数据?

提前致谢!

更新: 我知道这可以通过 here 中的补丁来完成,但如果可能的话,我需要通过 plt.scatter 来完成,因为我还将在同一个图上绘制另一组圆圈并使用与图表尺寸混淆的补丁(太薄了)。

【问题讨论】:

    标签: matplotlib markers


    【解决方案1】:

    linestyle='--' 传递给scatter

    plt.scatter(x, y, s=80, facecolors='none', edgecolors='r')
    plt.scatter(x2, y2, s=80, facecolors='none', edgecolors='r',
                linestyle='--')
    

    不过,对于那个标记大小,我宁愿使用linestyle=':'

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-03
    • 2020-03-31
    • 2013-06-19
    • 2014-02-20
    • 1970-01-01
    • 1970-01-01
    • 2016-04-26
    相关资源
    最近更新 更多