Last active
October 14, 2018 22:03
-
-
Save davidbody/1c2109012dfe0cffd50c1a67420eca11 to your computer and use it in GitHub Desktop.
Plotting the solution to the 12-Oct-2018 riddler about the goat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://fivethirtyeight.com/features/so-you-want-to-tether-your-goat-now-what/ | |
# Plot of solution from James Jones's code | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Circle | |
tether_length = 1.16 | |
fix, ax = plt.subplots() | |
field_circle = Circle((0, 0), 1, facecolor = "none", edgecolor = (0, 0.8, 0)) | |
goat_circle = Circle((1, 0), tether_length, facecolor = "none", edgecolor = (0, 0, 0.8)) | |
ax.add_patch(field_circle) | |
ax.add_patch(goat_circle) | |
ax.plot((1, 1 - tether_length), (0, 0), color = "black", alpha = 0.7, linestyle = ":") | |
ax.set_aspect(1.0) | |
ax.set_xlim(-1.5, 2.5) | |
ax.set_ylim(-1.5, 1.5) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment