[AstroPy] plot of data and residuals

Thomas Robitaille thomas.robitaille at gmail.com
Tue Aug 10 09:38:01 EDT 2010


Hi Jon,

The easiest way to do something like this is just to define your axes size relative to the figure:

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

fig = plt.figure()
ax1 = fig.add_axes([0.1,0.35,0.8,0.50])
ax2 = fig.add_axes([0.1,0.1,0.8,0.20])
fig.savefig('data_residuals.png')

The format of the axes specifications is [xmin, ymin, dx, dy]. You can then use ax1 and ax2 to plot in the respective axes.

Cheers,

Tom

On Aug 10, 2010, at 9:16 AM, Jonathan Slavin wrote:

> To AstroPy'ers:
> 
> I'd like to make a plot using matplotlib with two subplots, a larger one
> with the data and model and a lower (smaller height) abutting one with
> the residuals (sharing the x-axis).  Since this is a common sort of plot
> in astronomy, I thought maybe one of you might have figured out how to
> do this, saving me the trouble of figuring it out for myself.  I don't
> see any examples quite like that on the matplotlib examples page.  If I
> don't get any response, I'll do it myself and (if not too kludgey) will
> post my method.
> 
> Jon
> -- 
> ______________________________________________________________
> Jonathan D. Slavin              Harvard-Smithsonian CfA
> jslavin at cfa.harvard.edu         60 Garden Street, MS 83
> phone: (617) 496-7981           Cambridge, MA 02138-1516
> cell: (781) 363-0035           USA
> ______________________________________________________________
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy




More information about the AstroPy mailing list