[Matplotlib-users] twinx() multiple x-axes?
Hi matplotlib-users! OK, yeah, I'm pretty new to matplotlib/pylab... I played with biggles for a short while but, all (more than 3) my python-using associates in the astronomical community we saying matplotlib was the way of the future... So I started with matplotlib. I would like to plot some points, y vs x on a graph. y containing simple values, x is an angle. plot(x, y) -- that bit is fine, values as a function of angle. But what I need to do is then have an another labelling scheme on the upper x axes. This would be say, a distance, and so is simply a constant multiplied by the lower x. I figured there would be some way I could rescale the x-axis and write it at the top, but a way of accomplishing this I cannot find. I have been playing with twinx a bit but not getting very far. It's not that I want to plot 2 different datasets because the two are equivalent. Is it the non-existnt twiny() I am looking for? Or is there simply a way to redraw axes over the current ones with a certain range, that leaves the range in the first plot untouched? I have messed with twinx a bit and some of the discussion in the archive for this list but I can't figure out how to do it... Hope that makes sense? Sorry my first post was a beg for help Matt - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] making subplots with rows different sizes
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: X X X X X X X X 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 - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making subplots with rows different sizes
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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making subplots with rows different sizes
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 <[EMAIL PROTECTED]> 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@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Biophysics Graduate Student Carlson Lab, University of Michigan http://www.umich.edu/~mlerner http://lernerclan.net - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making subplots with rows different sizes
On 3/21/07, Michael Lerner <[EMAIL PROTECTED]> 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: > > X > X > X > X > > X > X > > X > X > > 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 - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] twinx() multiple x-axes?
use tick top: ax = twinx() ax.xaxis.tick_top() On Wed, 2007-03-21 at 18:17 +0100, Matthew Czesarski wrote: > Hi matplotlib-users! > > OK, yeah, I'm pretty new to matplotlib/pylab... I played with biggles > for a short while but, all (more than 3) my python-using associates in > the astronomical community we saying matplotlib was the way of the > future... So I started with matplotlib. > > I would like to plot some points, y vs x on a graph. y containing > simple values, x is an angle. plot(x, y) -- that bit is fine, values > as a function of angle. But what I need to do is then have an another > labelling scheme on the upper x axes. This would be say, a distance, > and so is simply a constant multiplied by the lower x. I figured there > would be some way I could rescale the x-axis and write it at the top, > but a way of accomplishing this I cannot find. > > I have been playing with twinx a bit but not getting very far. It's > not that I want to plot 2 different datasets because the two are > equivalent. Is it the non-existnt twiny() I am looking for? Or is > there simply a way to redraw axes over the current ones with a certain > range, that leaves the range in the first plot untouched? I have > messed with twinx a bit and some of the discussion in the archive for > this list but I can't figure out how to do it... > > Hope that makes sense? Sorry my first post was a beg for help > Matt > - > 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@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Rick Albright Senior Quantitative Analyst Indie Research, LLC 254 Witherspoon Street Princeton, NJ 08542 (609)497-1030 [EMAIL PROTECTED] - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making subplots with rows different sizes
John Hunter wrote: > On 3/21/07, Michael Lerner <[EMAIL PROTECTED]> 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: >> >> X >> X >> X >> X >> >> X >> X >> >> X >> X >> >> 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 - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Getting resize_event to work
Trying to get resize event to work, but either I don't understand the definition of when resize_event should work, or it's broken. for example === from matplotlib import pylab , numerix def GotResizeEvent( event ): print 'Resize event detected' def GotDrawEvent( event ): print 'Draw event detected' X = range(0, 200) Y = pylab.sin(X) r = pylab.plot(X,Y) pylab.connect( 'resize_event', GotResizeEvent) pylab.connect( 'draw_event', GotDrawEvent) pylab.show() = Will only get draw_events as I zoom in on the data, never a resize event? I also get draw_events as I resize the window itself, but never a resize_event. So my question, .. what user activity triggers a resize event? Numerix Version: numpy 1.0 MatPlotLib Version: 0.87.7 Steve - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] imshow, matshow coordinate system
Hi there, I'm pretty new to python; I'm in the process of switching from Matlab. I do quite a bit of image processing in my research, and while pylab/matplotlib seems to be a great plotting library, some of the quirks seem just a little bit frustrating - I'm hoping for some enlightenment :) When I use imshow or matshow to display an array, the points with index (m, n) are displayed with the pixels centred at (0.5 + m, 0.5 + n). Is there a setting somewhere to make it so that the centres of the pixels are at the index values rather than their bottom left corners? Or must I be always adding 0.5 to things to make them appear in the right places? Thanks, I appreciate any help Richard -- Richard Brown Ph.D. Candidate Dept. of Mechanical Engineering University of Canterbury, NZ - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] imshow, matshow coordinate system
Richard Brown wrote: > Hi there, > > I'm pretty new to python; I'm in the process of switching from Matlab. > I do quite a bit of image processing in my research, and while > pylab/matplotlib seems to be a great plotting library, some of the > quirks seem just a little bit frustrating - I'm hoping for some > enlightenment :) > > When I use imshow or matshow to display an array, the points with > index (m, n) are displayed with the pixels centred at (0.5 + m, 0.5 + > n). Is there a setting somewhere to make it so that the centres of the > pixels are at the index values rather than their bottom left corners? > Or must I be always adding 0.5 to things to make them appear in the > right places? Coincidentally, a few days ago I made this change for matshow; I had made it in spy some time ago. I have so far left imshow alone; isn't its present behavior consistent with Matlab? That is not necessarily a good reason for leaving it the way it is, but it is reason for some caution. I suspect quite a few people may prefer it the way it is; let's see who responds, and what opinions are voiced. One way of maintaining compatibility (if it is indeed compatible now, and if this is judged desirable) would be to add a kwarg and/or rc option. But if there is a consensus that imshow should by default put index ticks at cell centers, then I will be happy to make that change. Eric > > Thanks, I appreciate any help > > Richard - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] trig plot from event?
I have two plots. first one is velocity data from servo controller (freq) - plant reciprocates back and forth so we got turn data in there as well second one is psd (power spectral density) so we can see where we got resonances etc. When we zoom in on on section of first plot (say the forward movement), I'd like to recalc the psd with only the data that's been zoomed in on. Everything kind of works except for somewhere to trigger from. I had thought of trying resize_event - however I cannot get this working- see other post. I played with button_release_event to get the code basically working, however that event occurs before the first graph gets resized, so the region I am calculating the psd on is wrong, maybe because I am using xlim = myAxis.get_xlim() to find the limits of the first graph (which hasn't been re-drawn yet) Is there some way I can hook the re-calc/draw of psd to the zooming of first graph? Previously with 2 plot commands, I have used subplot(212, sharex=p1), to hook the two graphs together on the xaxis however as the second graph is a psd I don't know how to hook the psd input data to the xaxis of the first graph. Thanks Steve - 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users