## Re: [Matplotlib-users] making subplots with rows different sizes

 Re: [Matplotlib-users] making subplots with rows different sizes From: Michael Lerner - 2007-04-24 15:21:27 ```I recently attended a fantastic workshop by John Hunter and Fernando Perez, and John pointed out that I really do want to play with the axis objects directly. In case someone googles for this later on, here's how to do it for two boxes: ax = axes([0.1, 0.3, 0.8, 0.6]) plot(rand(12)) a2 = axes([0.1, 0.1, 0.8, 0.15]) plot(rand(12)) On 3/21/07, Eric Firing wrote: > John Hunter wrote: > > On 3/21/07, Michael Lerner wrote: > >> Hi, > >> > >> I want to make a figure that has three subplots. The top one should > >> be a big, mostly square thing. The bottom two should be rectangular > >> things. That is, I want it to look like this: > >> > >> XXXXX > >> XXXXX > >> XXXXX > >> XXXXX > >> > >> XXXXX > >> XXXXX > >> > >> XXXXX > >> XXXXX > >> > >> so, I'm using subplot(311), subplot(312), subplot(313). But, things > >> are getting resized so that each of the rows has the same height. > >> That really messes up the aspect ratio for my top row. > > > > The following might hrlp: > > > > ax1 = subplot(211) > > ax2 = subplot(413) > > ax3 = subplot(414) > > > > JDH > > And if you want to tweak the positions you can use, e.g., oldpos = > ax1.get_position() to find out the present position, and > ax1.set_position(newpos) to change it. The position rectangles are > [left, bottom, width, height] in relative coordinates--that is, > fractions of the figure width and height. > > If you want to control the aspect ratio of the data without changing the > position rectangle (e.g. after adjusting it as above), use > ax1.set_aspect(aspect, adjustable='datalim'). > > Eric > -- Biophysics Graduate Student Carlson Lab, University of Michigan http://www.umich.edu/~mlerner http://lernerclan.net ```

 [Matplotlib-users] making subplots with rows different sizes From: Michael Lerner - 2007-03-21 18:38:47 ```Hi, I want to make a figure that has three subplots. The top one should be a big, mostly square thing. The bottom two should be rectangular things. That is, I want it to look like this: XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX so, I'm using subplot(311), subplot(312), subplot(313). But, things are getting resized so that each of the rows has the same height. That really messes up the aspect ratio for my top row. I tried axis('equal') and axis('scaled') after making the first subplot. I do indeed get a good aspect ratio, but it shrinks things to do this, rather than stretching things. I'd really like the top row to be taller than the bottom rows. How can I do this? If it matters, I make the top box with pcolormesh and the bottom rectangles with plot. Thank you, -michael -- Biophysics Graduate Student Carlson Lab, University of Michigan http://www.umich.edu/~mlerner http://lernerclan.net ```
 Re: [Matplotlib-users] making subplots with rows different sizes From: Zack - 2007-03-21 19:05:06 ```Hi Michael, On 21 March 2007, Michael Lerner wrote: > so, I'm using subplot(311), subplot(312), subplot(313). But, things > are getting resized so that each of the rows has the same height. > That really messes up the aspect ratio for my top row. > > I tried axis('equal') and axis('scaled') after making the first > subplot. I do indeed get a good aspect ratio, but it shrinks things > to do this, rather than stretching things. I'd really like the top > row to be taller than the bottom rows. How can I do this? See the examples. You just have to set figure size you need. f = Figure(figsize=(5,4), dpi=100) -- Zack ```
 Re: [Matplotlib-users] making subplots with rows different sizes From: Michael Lerner - 2007-03-21 20:30:44 ```Hi, Sorry if I'm just being thick .. I read through several of the examples, and didn't figure it out. I can figure out how to use figsize to set the size of the entire figure, but I want several subplots on one figure. Maybe you can help me fix some sample code. This plots a matrix and sqrt(x)/2. I'd like to have the matrix show up as a square while sqrt(x)/2 shows up as a rectangle. The call to axis('scaled') makes my matrix show up as square, but I'd like it to be stretched out so that it uses up all of the horizontal space and makes the figure taller. That is, I want row 1 to be taller than row 2. Thanks, -Michael #!/usr/bin/env python from pylab import * subplot(211) mat = array([[1,2,3],[4,5,6],[7,8,9]]) pcolormesh(mat) axis('scaled') subplot(212) dt = 0.001 t = arange(0.0, 10.0, dt) root_t_over_2 = (t/2.0)**0.5 plot(t,root_t_over_2) show() On 3/21/07, Zack wrote: > Hi Michael, > > On 21 March 2007, Michael Lerner wrote: > > > so, I'm using subplot(311), subplot(312), subplot(313). But, things > > are getting resized so that each of the rows has the same height. > > That really messes up the aspect ratio for my top row. > > > > I tried axis('equal') and axis('scaled') after making the first > > subplot. I do indeed get a good aspect ratio, but it shrinks things > > to do this, rather than stretching things. I'd really like the top > > row to be taller than the bottom rows. How can I do this? > > See the examples. > > You just have to set figure size you need. > > f = Figure(figsize=(5,4), dpi=100) > > -- > Zack > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Biophysics Graduate Student Carlson Lab, University of Michigan http://www.umich.edu/~mlerner http://lernerclan.net ```
 Re: [Matplotlib-users] making subplots with rows different sizes From: John Hunter - 2007-03-21 20:38:59 ```On 3/21/07, Michael Lerner wrote: > Hi, > > I want to make a figure that has three subplots. The top one should > be a big, mostly square thing. The bottom two should be rectangular > things. That is, I want it to look like this: > > XXXXX > XXXXX > XXXXX > XXXXX > > XXXXX > XXXXX > > XXXXX > XXXXX > > so, I'm using subplot(311), subplot(312), subplot(313). But, things > are getting resized so that each of the rows has the same height. > That really messes up the aspect ratio for my top row. The following might hrlp: ax1 = subplot(211) ax2 = subplot(413) ax3 = subplot(414) JDH ```
 Re: [Matplotlib-users] making subplots with rows different sizes From: Eric Firing - 2007-03-21 21:36:30 ```John Hunter wrote: > On 3/21/07, Michael Lerner wrote: >> Hi, >> >> I want to make a figure that has three subplots. The top one should >> be a big, mostly square thing. The bottom two should be rectangular >> things. That is, I want it to look like this: >> >> XXXXX >> XXXXX >> XXXXX >> XXXXX >> >> XXXXX >> XXXXX >> >> XXXXX >> XXXXX >> >> so, I'm using subplot(311), subplot(312), subplot(313). But, things >> are getting resized so that each of the rows has the same height. >> That really messes up the aspect ratio for my top row. > > The following might hrlp: > > ax1 = subplot(211) > ax2 = subplot(413) > ax3 = subplot(414) > > JDH And if you want to tweak the positions you can use, e.g., oldpos = ax1.get_position() to find out the present position, and ax1.set_position(newpos) to change it. The position rectangles are [left, bottom, width, height] in relative coordinates--that is, fractions of the figure width and height. If you want to control the aspect ratio of the data without changing the position rectangle (e.g. after adjusting it as above), use ax1.set_aspect(aspect, adjustable='datalim'). Eric ```
 Re: [Matplotlib-users] making subplots with rows different sizes From: Michael Lerner - 2007-04-24 15:21:27 ```I recently attended a fantastic workshop by John Hunter and Fernando Perez, and John pointed out that I really do want to play with the axis objects directly. In case someone googles for this later on, here's how to do it for two boxes: ax = axes([0.1, 0.3, 0.8, 0.6]) plot(rand(12)) a2 = axes([0.1, 0.1, 0.8, 0.15]) plot(rand(12)) On 3/21/07, Eric Firing wrote: > John Hunter wrote: > > On 3/21/07, Michael Lerner wrote: > >> Hi, > >> > >> I want to make a figure that has three subplots. The top one should > >> be a big, mostly square thing. The bottom two should be rectangular > >> things. That is, I want it to look like this: > >> > >> XXXXX > >> XXXXX > >> XXXXX > >> XXXXX > >> > >> XXXXX > >> XXXXX > >> > >> XXXXX > >> XXXXX > >> > >> so, I'm using subplot(311), subplot(312), subplot(313). But, things > >> are getting resized so that each of the rows has the same height. > >> That really messes up the aspect ratio for my top row. > > > > The following might hrlp: > > > > ax1 = subplot(211) > > ax2 = subplot(413) > > ax3 = subplot(414) > > > > JDH > > And if you want to tweak the positions you can use, e.g., oldpos = > ax1.get_position() to find out the present position, and > ax1.set_position(newpos) to change it. The position rectangles are > [left, bottom, width, height] in relative coordinates--that is, > fractions of the figure width and height. > > If you want to control the aspect ratio of the data without changing the > position rectangle (e.g. after adjusting it as above), use > ax1.set_aspect(aspect, adjustable='datalim'). > > Eric > -- Biophysics Graduate Student Carlson Lab, University of Michigan http://www.umich.edu/~mlerner http://lernerclan.net ```