## DEV Community 👩‍💻👨‍💻 is a community of 915,052 amazing developers

We're a place where coders share, stay up-to-date and grow their careers. # Plotting a circle in python with angles.

I have got some hard time dealing with angles in space, and because i skipped all of my geometry class i had no idea how to imagine angles in a circle so i decided to find a way to plot them using python

## First lets Import Modules

``````import matplotlib.pyplot as pl
from numpy import sin, cos, pi, linspacet
``````

## Adding a center point

``````plt.plot(0,0, color = 'red', marker = 'o')
`````` ## Adding a circle

``````r = 1.5
angles = linspace(0 * pi, 2 * pi, 100)
print(angles)
xs = cos(angles)
ys = sin(angles)

plt.plot(xs, ys, color = 'green')
plt.xlim(-r, r)
plt.ylim(-r, r)
plt.gca().set_aspect('equal')
`````` ## Drawing diameter

``````plt.plot(r-0.5, 0, marker = 'P', color = 'blue')
plt.plot(-r+0.5, 0, marker = 'o', color = 'red')
plt.plot([r, -r], [0, 0], color = 'red')
`````` ## A function to convert from Degree to Radian

``````def deg2rad(deg):
return deg * pi / 180
``````

## Now lets draw two lines at 90° and 45°

``````plt.plot([0, r * cos(deg2rad(90))], [0, r * sin( deg2rad(90))], color = "red")
plt.plot([0, r * cos(deg2rad(45))], [0, r * sin( deg2rad(45))], color = "black")

``````

## Show the final result

``````plt.savefig('angles.png')
``````

Hope that article would save some time.

## Top comments (0)

#### Head to your account's Settings to...

🌚 Enable dark mode
🔠 Change your default font
📚 Adjust your experience level to see more relevant content