Created
July 17, 2013 16:12
-
-
Save adrn/6022030 to your computer and use it in GitHub Desktop.
API for astropy.units aware plotting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# API for unit-aware plotting | |
theta1 = np.random.uniform(0., 360., size=100)*u.degree | |
phi1 = np.random.uniform(-90., 90., size=100)*u.degree | |
theta2 = np.random.uniform(0., 24., size=50)*u.hourangle | |
phi2 = np.random.uniform(-90., 90, size=50)*u.degree | |
ax = fig.add_subplot(111) | |
ax.plot(theta1, phi1) | |
ax.plot(theta2, phi2) | |
# default units are degrees, because those were plotted first | |
# can change units like this | |
ax.set_xunits(u.hourangle) | |
ax.set_yunits(u.radian) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment