Matplotlib散点图中的部分填充圆圈

发布于 2025-01-30 04:08:27 字数 553 浏览 3 评论 0原文

我目前正在尝试在Matplotlib散点图中绘制一个部分填充的圆圈。 “ nofollow noreferrer”>半填充或空圆圈。 我想要的是类似于以下图像的内容:

在这里,我希望能够控制它,例如,第2-6节以特定的标记显示,而其他标记则显示不同的范围。

Matplotlib是否支持这样的东西?我知道我可能需要将圆圈分为12个部分并为它们分配特定的颜色,但我不知道该怎么做。

I am currently trying to plot a partially filled circle in the matplotlib scatter plot.
The marker fill styles on the official documentation offers only half-filled or empty circles.
What I want is something similar to the following image:
enter image description here

Here I want to be able to control that, e.g., only the section 2-6 show up in a specific marker, while other markers show different ranges.

Does matplotlib support something like this? I understand that I probably need to partition the circle into 12 sections and assign them a specific color, but I don't know how to do that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2025-02-06 04:08:27

在这里,您需要一个标记所需的代码,然后仅在X0,Y0上迭代,并用白色作为颜色作为所希望的“消失”段。

import matplotlib.pylab as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(1,1,1, aspect='equal')

x0 = 0.2
y0 = 0.7
rho_marker = 0.05
n_marker = 14
theta = np.zeros((12, n_marker))

for j in range(12):
    theta[j, :] = np.linspace(float(j)/6.*np.pi, float(j+1)/6.*np.pi, n_marker)
    x = x0 + np.append(0, rho_marker*np.cos(theta[j]))
    y = y0 + np.append(0, rho_marker*np.sin(theta[j]))
    ax.fill(x, y)
plt.xlim([0, 1])
plt.ylim([0, 1])
plt.show()

在这里,由此产生的情节:

Here the code you need for one marker, then just iterate over x0, y0 and use white as color for the wished "vanishing" segments.

import matplotlib.pylab as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(1,1,1, aspect='equal')

x0 = 0.2
y0 = 0.7
rho_marker = 0.05
n_marker = 14
theta = np.zeros((12, n_marker))

for j in range(12):
    theta[j, :] = np.linspace(float(j)/6.*np.pi, float(j+1)/6.*np.pi, n_marker)
    x = x0 + np.append(0, rho_marker*np.cos(theta[j]))
    y = y0 + np.append(0, rho_marker*np.sin(theta[j]))
    ax.fill(x, y)
plt.xlim([0, 1])
plt.ylim([0, 1])
plt.show()

Here the resulting plot:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文