-1

does anyone know how you can accomplish the task in the title. I want to plot something like displayed in this question.

Thank you for your help!

MattDMo
  • 100,794
  • 21
  • 241
  • 231
Cion
  • 85
  • 8
  • Stack Overflow is not a code-writing or tutorial service. Please [edit] your question and post [what you have tried so far](https://meta.stackoverflow.com/q/261592), including example input, expected output, the actual output (if any), and the **full text** of any errors or tracebacks, *all as formatted text in the question itself.* Do not post images of text. – MattDMo Aug 17 '21 at 13:09
  • https://stackoverflow.com/questions/9215658/plot-a-circle-with-pyplot – Mark Lavin Aug 17 '21 at 13:11

1 Answers1

0

Got it working with this code here with particles being an array with x, y and angle.

figure, axes = plt.subplots()
axes.set_xlim((0,50))
axes.set_ylim((0,50))
axes.set_aspect(1)
for i in range(M):
    axes.add_artist(plt.Circle((particles[i,0], particles[i,1]), 1.5, color='g', alpha=0.5))
plt.title('Circle')

lines = np.empty((M, 2))
for i in range(M):
    lines[i,0] = radius*math.cos(particles[i,2]*180/np.pi) + particles[i,0]
    lines[i,1] = radius*math.sin(particles[i,2]*180/np.pi) + particles[i,1]
    plt.plot([particles[i,0], lines[i,0]], [particles[i,1], lines[i,1]], 'k')

plt.show()
Cion
  • 85
  • 8