[AstroPy] APLpy color bar for markers
Ke Wang
kwang at eso.org
Mon Mar 7 16:03:24 EST 2016
Thank you Thøger!
I got this error, which I don't understand. Any idea ?
In [19]: f.colorbar(ax=a, use_gridspec=True)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-19-a7064055af74> in <module>()
----> 1 f.colorbar(ax=a, use_gridspec=True)
TypeError: colorbar() takes at least 2 arguments (3 given)
---
Dr. Ke Wang
Associate, European Southern Observatory
http://www.eso.org/~kwang
On Mon, Mar 7, 2016 at 6:55 PM, Thøger Emil Rivera-Thorsen <
trive at astro.su.se> wrote:
> Sorry for flooding, but I just worked out a better solution:
>
> import matplotlib.pyplot as pltimport aplpy as ap
>
> f = plt.figure()
> fig = ap.FITSFigure('/path/to/myimage.fits', figure=f)
> a = fig.axes[0] # Or alternatively, a = plt.gca()
> x, y = fig.world2pixel(ra, dec)
>
> points = a.scatter(x, y, c=velocity, cmap='rainbow')
> f.colorbar(ax=a, use_gridspec=True)
>
> This should give you what you want, and look a good deal nicer than my
> first suggestion.
> You can set the width etc. of the colorbar in the f.colorbar() call, just
> read the documentation (f.colorbar? in IPython).
>
> On 03/07/2016 06:38 PM, Thøger Emil Rivera-Thorsen wrote:
>
> I would do this by tapping directly into the Matplotlib/pylab api to do
> this:
>
> import matplotlib.pyplot as pltimport aplpy as ap
>
> fig = ap.FITSFigure('myimage.fits')
> fig.show_grayscale()
>
> f, a = plt.gcf(), plt.gca()
> x, y = fig.world2pixel(ra, dec)
>
> points = a.scatter(ra, dec, c=velocity, cmap='rainbow')
> fig.colorbar(points)
>
> The colorbar is not as neatly aligned as the APLPy function does, but this
> can be refined and tweaked, if you read the matplotlib docs (or you can
> just use it as-is).
>
> On 03/07/2016 04:52 PM, Ke Wang wrote:
>
> Hi,
>
> This should be a simple question, but I just don't find an obvious
> solution:
>
> I use APLpy to plot a FITS image with nice wcs coordinates support, and
> overlay color coded markers:
>
> fig = aplpy.FITSFigure('image.fits')
> fig.show_colorscale(cmap='gray')
> fig.show_markers(ra, dec, c=velocity, cmap='rainbow')
> fig.add_colorbar()
>
> This will plot a gray color bar (for the image). But I want to display the
> rainbow (for markers). Any idea would be appreciated.
>
> Cheers,
> Ke
>
>
> _______________________________________________
> AstroPy mailing listAstroPy at scipy.orghttps://mail.scipy.org/mailman/listinfo/astropy
>
>
>
>
> _______________________________________________
> AstroPy mailing listAstroPy at scipy.orghttps://mail.scipy.org/mailman/listinfo/astropy
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20160307/2ef8605e/attachment.html>
More information about the AstroPy
mailing list