Skip to content

Instantly share code, notes, and snippets.

@benjaminrose
Created February 19, 2015 19:51
Show Gist options
  • Save benjaminrose/ac53f02839b9c7a37dc7 to your computer and use it in GitHub Desktop.
Save benjaminrose/ac53f02839b9c7a37dc7 to your computer and use it in GitHub Desktop.
An example of using all sky projections in matplotlib.pyplot.
import matplotlib.pyplot as plt
import numpy as np #casue it rocks
# get random values to plot
#needs to be in radians from (-pi,pi) & (-pi/2, pi/2)
a = np.random.rand(100)*2*np.pi - np.pi
d = np.random.rand(100)*np.pi - np.pi/2
#todo(make values astropy.cooridnates and use wrap_at(180*u.degree). Allows for more varriable data.
#make figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='hammer' ) # or mollweide, aitoff, or lambert. [example](http://matplotlib.org/examples/pylab_examples/geo_demo.html)
ax.scatter(a,d, marker='*', color='y')
ax.grid(True)
ax.set_xticklabels(['14h','16h','18h','20h','22h','0h','2h','4h','6h','8h','10h']) #use if you want to change to a better version of RA.
plt.xlabel('RA')
plt.ylabel(r'$\delta$')
plt.show()
fig.savefig('allsky.pdf')
@benjaminrose
Copy link
Author

You can see the output file here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment