# Import the plotting library import matplotlib.pyplot as plt # import the numerical library import numpy as np number_of_multiplanet_systems = 657 number_of_confirmed_planets = 3916 print("Hello World. On 14th February 2019 there are 3 917 confirmed planets.") print("Tthe number of multi-planet systems is {:d}.".format(number_of_confirmed_planets)) print("There are {:3.2f} planets/system, on average".format( float(number_of_confirmed_planets)/float(number_of_multiplanet_systems))) # Create an array of N zero elements N = 1000 vec = np.zeros(N) # Create an array of N linearly spaced elements from -pi to pi phi = np.linspace(-np.pi, np.pi, N) # Create sine and cosine vectors x = 0.5*np.cos(phi) y = 1.0*np.sin(phi) # Define figure and axes fig, (ax0, ax1) = plt.subplots(ncols=1, nrows=2, num=31415) # Plot vectors and add decorations ax0.plot(phi, x, color='red', label='cos(phi)') ax0.plot(phi, y, color='blue', label='sin(ph i)') ax0.set_xlabel("$\phi$ [rad]") # Note: labels can use Latex notation within $$ symbols ax0.set_ylabel("Function") ax0.grid() ax0.legend() ax1.plot(x, y, color='black', label='This is an ellipse') ax1.set_xlabel("x") ax1.set_ylabel("y") ax1.set_xlim(-1.1, 1.1) ax1.set_ylim(-1.1, 1.1) ax1.grid() ax1.legend() plt.show()