import numpy as np from matplotlib import pyplot as plt %matplotlib inline a = 6378.1370 b = 6356.7523 lat = np.linspace(0,90,90) latr = np.radians(lat) denom = (a * np.cos(latr))**2. + (b * np.sin(latr))**2. numer = (a**2. * np.cos(latr))**2. + (b**2. * np.sin(latr))**2. R = np.sqrt(numer/denom) plt.plot(lat, R) plt.show() mountains = """ Summit, Distance from center, Elevation above sea level, Latitude, Country Chimborazo, 6384.4, 6268.2, -1.469167, Ecuador Huascaran, 6384.4, 6748, -9.121389, Peru Kilimanjaro, 6383, 5895, -3.075833, Tanzania Everest, 6382.3, 8848, 27.988056, Nepal """ m = filter(None, mountains.split('\n')) # Start the plot. plt.figure(figsize=(12,12)) ax = plt.subplot(111) ax.plot(lat[:40], R[:40]) # Iterate over the mountains, skipping the first. for row in m[1:]: # Make a list out of each row. data = row.split(',') # Extract data we can use. deg = np.abs(np.round(float(data[3]),0)) ht = float(data[2])/1000. # Add to the plot. ax.axhline(R[deg]+ht, color="lightgray") ax.vlines(np.abs(float(data[3])), R[deg], R[deg]+ht) ax.text(deg+0.5, R[deg]-1, data[0], fontsize=12, rotation=90, horizontalalignment='right') ax.text(deg+0.5, 1.0004*(R[deg]+ht), str(np.round(R[deg]+ht,3))+" km" , fontsize=10, rotation=90, horizontalalignment='right') # Adjust and show the plot. ax.set_xlim(-5, 45) ax.set_ylim(6370, 6390) plt.xlabel('Absolute latitude in degrees') plt.ylabel("Distance from Earth's centre") plt.show()