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:
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_(x|y)units) in the transformations. Perhaps someone can
enlighten me. It doesn't really matter until one tries non-linear
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 sub-function should be moved out
of plotyy so it can be reused. Also, I couldn't find a way to color the
actual y-axis - i.e. the vertical line that is the y-axis. Is there an
easy way to do this?
text_rotation.patch (5.59 KB)
plotyy.patch (2.43 KB)
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
34203 Sete cedex
Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95