astrofrog / wcsaxes

wcsaxes has been merged into astropy!
http://docs.astropy.org/en/stable/visualization/wcsaxes/index.html
22 stars 21 forks source link

Add scalebar or scalebar example #192

Open keflavich opened 8 years ago

keflavich commented 8 years ago

It's all in the title. I'm sure I've done this once or twice, so I'll try to include a snippet...

keflavich commented 8 years ago

Snippet example:

scalebar_right = coordinates.SkyCoord("19h23m40s", "14d29m45s", frame='fk5')
length = (0.5*u.pc / (5400*u.pc)).to(u.deg, u.dimensionless_angles())
ax.plot([scalebar_right.ra.deg, (scalebar_right.ra-length).deg]*u.deg,
        [(scalebar_right.dec).deg]*2*u.deg,
        'k',
        transform=tr_fk5,
        zorder=100, linewidth=2)
ax.text((scalebar_right.ra-length/2).deg, (scalebar_right.dec+0.001*u.deg).deg,
        "0.5 pc", color='k', transform=tr_fk5, ha='center')
astrofrog commented 8 years ago

@keflavich - can we make a Scalebar class that would be a matplotlib Patch subclass? (and it could take the WCS as an argument)

astrofrog commented 8 years ago

Just to clarify, I think it would be great to do:

from wcsaxes import Scalebar

# create WCSAxes here

ax.add_patch(Scalebar(location='bottom-right', length=3 * u.arcsec,
                      wcs=wcs, pad=0.1, label='300 au'))

And this would place it at (0.9, 0.1) in relative axis units and figure out the right length?

keflavich commented 8 years ago

I like the idea. Won't implement it until I desperately need it, though.

astrofrog commented 8 years ago

DDD = desperation driven development