|
From: Benjamin R. <ben...@ou...> - 2013-03-22 16:40:15
|
On Fri, Mar 22, 2013 at 12:30 PM, Steven Boada <bo...@ph...>wrote: > Well... I jumped the gun. To better illustrate the problem(s) I am having, > I wrote a simple script that doesn't work... > > import pylab as pyl > from mpl_toolkits.axes_grid1 import AxesGrid > > # make some data > xdata = pyl.random(100) * 25. > ydata = pyl.random(100) * 8. > colordata = pyl.random(100) * 3. > > # make us a figure > F = pyl.figure(1,figsize=(5.5,3.5)**) > grid = AxesGrid(F, 111, > nrows_ncols=(1,2), > axes_pad = 0.1, > add_all=True, > share_all = True, > cbar_mode = 'each', > cbar_location = 'top') > > # Plot! > sc1 = grid[0].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') > sc2 = grid[1].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') > > # Add colorbars > grid.cbar_axes[0].colorbar(**sc1) > grid.cbar_axes[1].colorbar(**sc2) > > grid[0].set_xlim(0,25) > grid[0].set_ylim(0,8) > > pyl.show() > > > And you get some squashed figures... I'll attach a png. > > Thanks again. > > Steven > > You used AxesGrid again, not Grid. AxesGrid implicitly applies an aspect='equal' to the subplots. This means that a unit of distance on the x-axis takes the same amount of space as the same unit of distance on the y-axis. In your example, the x axis goes from 0 to 25, while the y-axis goes from 0 to 8. When aspect='equal', the y-axis will then be about a third the size of the x-axis, because the y-limits are about a third the size of the x-limits. Ben Root |