Kepler’s Third Law

Inspired by this plot: https://commons.wikimedia.org/wiki/File:Solar_system_orbital_period_vs_semimajor_axis.svg

keplers third

Out:

(0.2, 200)

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.DataFrame([
    # object, semi-major axis (AU), orbital period (year), color
    ('Mercury', 0.387098, 0.240846, '#6d696a'),
    ('Venus', 0.723332, 0.615198, '#d4d0ca'),
    ('Earth', 1.0, 1.0, '#787cac'),
    ('Mars', 1.523679, 1.88085, '#e37c5b'),
    ('Jupiter', 5.2044, 11.862, '#c58035'),
    ('Saturn', 9.5826, 29.4571, '#e9c385'),
    ('Uranus', 19.19126, 84.0205, '#8ba1ae'),
    ('Neptune', 30.07, 164.8, '#728ebd'),
], columns=['name', 'a', 'T', 'color'])

for _, row in df.iterrows():
    plt.loglog(row['a'], row['T'], c=row['color'], ls='', marker='o')
    plt.text(row['a']*1.1, row['T']*0.9, row['name'])

plt.grid(which='both', alpha=0.5)
plt.xlabel('Semi-major axis [AU]')
plt.ylabel('Orbital period [yr]')
plt.xlim(0.2, 200)

Total running time of the script: ( 0 minutes 1.305 seconds)

Gallery generated by Sphinx-Gallery