Skip to content

Instantly share code, notes, and snippets.

@adrn
Created July 17, 2013 16:12
Show Gist options
  • Save adrn/6022030 to your computer and use it in GitHub Desktop.
Save adrn/6022030 to your computer and use it in GitHub Desktop.
API for astropy.units aware plotting
# 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