[AstroPy] aplpy.FITSFigure combined with mpl subplots ?

Joseph Booker joe at neoturbine.net
Wed Jun 18 10:09:41 EDT 2014


Grigoris,

The problem with your code is that the plt.subplots() command creates
normal Axes objects, while FITSFigure creates a new axes every time you
create a FITSFigure(). If you did add a FITSFigure using subplot=[..], then
you'd simply overlap the regular axes with a HostAxes from FITSFigure,
instead of reusing the Axes.

I think this can be solved elegantly using the tuple notation to iterate
over the images:

f = plt.figure()
for i, obj in enumerate(list_of_images):
    aplpy.FITSFigure(obj, subplot=(rows,columns,i), figure=f)

This has the advantage of not creating extra axes if you don't have enough
images.

Good luck,
Joseph


On Wed, Jun 18, 2014 at 9:52 AM, Grigoris Maravelias <
gr.maravelias at gmail.com> wrote:

> Hello all!
>
> How can we combine the aplpy.FITSFigure within the matplotlib subplots?
>
> I am using this:
>  f, ax = plt.subplots(rows,columns) #, sharex='col', sharey='row')
>  index_list = [ind for ind in np.ndindex(rows,columns)]
>  ii = 0
>
>  for obj in list_of_images:
>     plot_index = index_list[ii]
>     ax[plot_index].plot(x,y)
>     ii += 1
>
> which works perfectly (iterating over all indeces, as we do not know
> their number beforehand and may change from one object to another).
> and we want now to add the the aplpy.FITSFigure of a fits file.
>
> What is the best way to pass this ?
>
> On the other hand I could take advantage of the subplot of
> aplpy.FITSFigure(obj,figure=fir,subplot=[...]) but I would like to
> automatically assign the positions of the subplots.
> Is there an easy way to use the indexing that I show previously (i.e.
> ax[plot_index])?
>
> Best
> Grigoris
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20140618/94101c8f/attachment.html>


More information about the AstroPy mailing list