I am currently trying to plot a partially filled circle in the matplotlib scatter plot. The
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.
CodePudding user response:
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()