import matplotlib.pyplot as plot from numpy import linspace, sin, cos, pi period = { "mercury": 87.96926, "venus": 224.7008, "earth": 365.25636, "mars": 686.97959, "ceres": 1680.22107, "jupiter": 4332.8201, "saturn": 10755.699, "uranus": 20687.153, "neptune": 60190.03, } dist = lambda T: T ** (2 / 3) # Kepler def plot_orbit(ax, planet1, planet2, periods=10): T1 = period[planet1] T2 = period[planet2] d1 = dist(T1) d2 = dist(T2) theta = linspace(0, 2 * pi * periods, 1000) x = d1 * cos(T2 * theta / T1) - d2 * cos(theta) y = d1 * sin(T2 * theta / T1) - d2 * sin(theta) # ax.plot.gca().set_aspect("equal") # ax.plot.axis('off') ax.plot(x, y) # plt.show() fig = plot.figure() ax = fig.add_subplot(2, 2, 1) plot_orbit(ax, "venus", "earth", 8) ax = fig.add_subplot(2, 2, 2) plot_orbit(ax, "jupiter", "saturn", 4) ax = fig.add_subplot(2, 2, 3) plot_orbit(ax, "uranus", "earth", 57) ax = fig.add_subplot(2, 2, 4) plot_orbit(ax, "mercury", "venus", 9) plot.show()