Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@thoolihan
Created October 27, 2016 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoolihan/7bd40d9be73ee532479df952028fec1b to your computer and use it in GitHub Desktop.
Save thoolihan/7bd40d9be73ee532479df952028fec1b to your computer and use it in GitHub Desktop.
Calculating and graphing a partial circle and inner circle in python
import numpy as np
import matplotlib.pyplot as plt
from math import pi, cos, sin
arc_size = pi / 2
points = 20
inner_ratio = .4
theta = np.arange(0, arc_size, arc_size / points)
x1 = np.array([cos(t) for t in theta])
y1 = np.array([sin(t) for t in theta])
x2 = inner_ratio * x1
y2 = inner_ratio * y1
plt.plot(x1, y1, 'b.', label="Radius 1")
plt.plot(x2, y2, 'r.', label="Radius %.1f" % inner_ratio)
plt.title("Partial Circle")
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment