gpt4 book ai didi

Matplotlib 绘制虚线圆圈

转载 作者:行者123 更新时间:2023-12-02 00:49:30 26 4
gpt4 key购买 nike

鉴于以下情况:

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 来完成,因为我还将在同一图上绘制另一组圆圈,并使用与图表尺寸混淆的补丁(太薄了)。

最佳答案

linestyle='--' 传递给 scatter

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

enter image description here

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

关于Matplotlib 绘制虚线圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41106312/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com