From: David A. <irb...@gm...> - 2011-05-11 22:18:32
|
Hi, I've come across something I don't entirely understand in the behaviour of gridspec. It's not obvious from the code & docs for this module, but is it only supposed to be able to deal with 'square' layouts, e.g. 3x3, 4x4 etc? Taking some code from an example on the gridspec page ... import matplotlib.pylab as plt import matplotlib.gridspec as gridspec #gs = gridspec.GridSpec(3, 3) # OK gs = gridspec.GridSpec(6, 3) # Will cause an error later on ax1 = plt.subplot(gs[0, :]) ax2 = plt.subplot(gs[1,:-1]) ax3 = plt.subplot(gs[1:,-1]) ax4 = plt.subplot(gs[-1,0]) ax5 = plt.subplot(gs[-1,-2]) plt.show() ... will fail if that line is uncommented, giving an index error. I don't see any reason why these slices should fail however, though obviously it won't use all the available space within the whole grid? Substituting a 'square' grid for the (6,3), e.g. (4,4), (5,5) etc seems to be fine though. I'm quite interested in getting involved with mpl development, partly as a way to get my head around python & numpy and aid porting a bunch of stuff I use over to python from IDL. Unless I'm doing something totally wrong by expecting the above snippet to work, then I'd happily spend some time looking into this in more detail, having written some similar code in IDL. The docs for that module also look like they could benefit from some work. Cheers, Dave --------- David Andrews PhD Student, Radio & Space Plasma Physics Group, University of Leicester, UK |