Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
Close
From: David Kaplan <David.K<aplan@ir...>  20080725 14:10:27
Attachments:
text_rotation.patch
plotyy.patch

Hi, Attached are two patch sets for you to review and comment on. I am not intending for these to go in this release. One is the beginning of a patch set that lets you choose whether text rotation angle is with respect to screen or axes coordinates. The idea is that you might want text that is properly rotated with respect to some object in a plot (e.g., contours), as opposed to being at some particular angle with respect to screen coordinates. Along the way I added a method to transforms.py that transforms angles at a location. The method included is generic and not at all optimized for simple linear transforms, but it works fairly well. This transform might be useful for other functions (e.g., quiver?). This patch basically works. For example, try the following: plot(arange(5)) th = text(3,3,'abcd',rotation=45,rotationscreen=False) th2 = text(2,2,'ABCD',rotation=45) and then try changing the size of your plot window. 'abcd' doesn't rotate with respect to the line as the window changes size, but 'ABCD' does. There are still some imperfections  the text seems to move above or below the line  I am not sure why this is. Also, I have no idea whether I should be using unitless (self._x,_y) or unitful coordinates (self.convert_(xy)units) in the transformations. Perhaps someone can enlighten me. It doesn't really matter until one tries nonlinear transformations (aka basemap). I also haven't tried to integrate this into TextWithDash. I imagine it can be done, but I wasn't sure it was worth the effort since TextWithDash is mostly used for axes ticks I believe. I am thinking of just forcing rotationscreen to True for this class. Comments? Once these issues are worked out, I would integrate this into contour.py so that windows can be resized without affecting label rotation. The second patch is to pyplot.py to create a plotyy function. This is like a matlab function of the same name that puts two curves with different y ranges on the same x axis. It basically wraps the two_scales.py demo functionality with a bit of extra stuff. I had to use a real hack to change the colors of the y axes. Perhaps someone can think of a better way or perhaps this subfunction should be moved out of plotyy so it can be reused. Also, I couldn't find a way to color the actual yaxis  i.e. the vertical line that is the yaxis. Is there an easy way to do this? Cheers, David  ********************************** David M. Kaplan Charge de Recherche 1 Institut de Recherche pour le Developpement Centre de Recherche Halieutique Mediterraneenne et Tropicale av. Jean Monnet B.P. 171 34203 Sete cedex France Phone: +33 (0)4 99 57 32 27 Fax: +33 (0)4 99 57 32 95 http://www.ur097.ird.fr/team/dkaplan/index.html ********************************** 
From: Ryan May <rmay31@gm...>  20080725 18:59:56

David Kaplan wrote: > The second patch is to pyplot.py to create a plotyy function. This is > like a matlab function of the same name that puts two curves with > different y ranges on the same x axis. It basically wraps the > two_scales.py demo functionality with a bit of extra stuff. I had to > use a real hack to change the colors of the y axes. Perhaps someone can > think of a better way or perhaps this subfunction should be moved out > of plotyy so it can be reused. Also, I couldn't find a way to color the > actual yaxis  i.e. the vertical line that is the yaxis. Is there an > easy way to do this? Do you have an example of how to use this (or at least what the results look like)? I'm having trouble seeing how this differs from twinx. Ryan  Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma 
From: David Kaplan <David.K<aplan@ir...>  20080729 14:20:47

Hi, Sorry I didn't respond to this immediately  I have had my mind on other things. plotyy is basically a wrapper around twinx that provides a bit of extra/builtin functionality. The idea is that you have two curves with similar x values, but different y that you want to plot together. It plots them both using twinx, but to help with visualisation, it changes the color of each curve and associated axis so that they are easy to distinguish (e.g., left blue, right green). This is also similar to a matlab function of the same name, so it helps us matlab converts out. An example of using this function might be: x = linspace(0,pi,20) y = sin(x) x2 = linspace(0.1,pi0.1,20) y2 = cos(x2) axs,h1,h2=plotyy(x,y,x2,y2) axs is a list with [ax1,ax2]. As is evident from the code itself, there isn't too much beyond what twinx already does, but this code aids matlab compatibility and also the recursive handle property change is useful. But this recursive code could be extricated to provide a general setp_recursive function that would change a property on an object and all its children (that have that property) if that is of interest. Cheers, David On Fri, 20080725 at 15:00 0400, Ryan May wrote: > David Kaplan wrote: > > The second patch is to pyplot.py to create a plotyy function. This is > > like a matlab function of the same name that puts two curves with > > different y ranges on the same x axis. It basically wraps the > > two_scales.py demo functionality with a bit of extra stuff. I had to > > use a real hack to change the colors of the y axes. Perhaps someone can > > think of a better way or perhaps this subfunction should be moved out > > of plotyy so it can be reused. Also, I couldn't find a way to color the > > actual yaxis  i.e. the vertical line that is the yaxis. Is there an > > easy way to do this? > > Do you have an example of how to use this (or at least what the results > look like)? I'm having trouble seeing how this differs from twinx. > > Ryan >  ********************************** David M. Kaplan Charge de Recherche 1 Institut de Recherche pour le Developpement Centre de Recherche Halieutique Mediterraneenne et Tropicale av. Jean Monnet B.P. 171 34203 Sete cedex France Phone: +33 (0)4 99 57 32 27 Fax: +33 (0)4 99 57 32 95 http://www.ur097.ird.fr/team/dkaplan/index.html ********************************** 