Re: [matplotlib-devel] SVG clickable images
Hi, I've attached a diff file which implements the basic functionality. It currently doesn't handle collections or draw_image, but I wanted to get something simple working first, before expanding the scope. A simple test program is as follows: from pylab import * f = figure() a,b = bar([1,2], [2,5], url='http://www.bbc.co.uk/') a.set_url('http://www.google.com') f.canvas.print_figure(r'c:\test.svg') I'd be interested in comments / feedback on the attached before I start to branch out into more significant changes! Thanks Andrew On Thu, Oct 30, 2008 at 8:02 PM, Michael Droettboom <[EMAIL PROTECTED]> wrote: > I realised in my earlier message, I didn't really address your initial > request for feedback on your approach. > > I think the goal here should be to make the url support as pervasive as > possible wrt both plot types and backends. > > Many of the high-level plotting functions (such as bar()) take a standard > set of "Artist" keywords. In the docs, you'll often see a table like the > one at the bottom for bar(): > > http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.bar > > This support all happens automatically simply by adding a setter and getter > to the "Artist" class. So, in Artist, simply add set_url/get_url methods > and a private attribute to store the url. You shouldn't have to touch any > of the high-level plotting functions to have this supported everywhere where > it makes sense. > > Then, to use the url value, you'll want to store it in a GraphicsContext > object to pass to the backend. So you'll want to add an attribute and > getter/setter in GraphicsContextBase as well. > > All of the places where the front-end creates a gc and passes it to the > backend will need to be updated (such as Artist.draw, Text.draw, perhaps > others, do a grep for the public methods in RendererBase). Where it sets > things like facecolor on the GraphicsContext, it should also set a url. > > Then, in backends where appropriate you would use the url value if present. > You could start with SVG, and maybe someone can come along and add PDF > support later. > > An additional complication for completeness is handling Collections. > Collections store a list of graphics context information (facecolor, > edgecolor etc.) rather than a single one. Therefore, you'll want to add > set_urls/get_urls to Collection as well, and then deal with passing those > values to the backend. Collections don't use a GraphicsContext class, so > you'll need to add a new arg to draw_path_collection in all backends. > (Refactoring this so we pass an object to the backends rather than a long > list of arguments would be welcome to avoid needing to update multiple > backends for these sorts of new features in the future). You will also need > to update RendererBase._iter_collection to support iterating over URLs in > the same way as everything else there. > > draw_image also doesn't use a gc, so you'll need to add an argument there. > > Hope that gives you a road map... Please let me know if I can help further. > > Mike > > Andrew Stock wrote: >> >> Hi, >> >> I have a requirement to make clickable bar charts using the SVG output >> (rather than html maps). >> >> An initial look has suggested that the following changes would be >> required: >> >> backend_bases.py: Add a url property to GraphicsContextBase >> (defaulting to None, so it's all backwards compatible) >> axes.py: Add a url option to the bar function and pass this on to the >> constructor of the Rectangle object >> patches.py: Pass the url option in the constructor for the Patch >> object to the GraphicsContextBase object created in the draw function >> backends/backend_svg.py: Add check to _draw_svg_element for url set in >> gc. If it is, write out SVG code for xlink. >> >> I can make these changes and (if people think it would be useful) >> contribute the changes back. However, before I do this, I wanted to >> check whether this is the right approach to take - I'm not experienced >> with the internals of matplotlib and so if there's a better way of >> doing it, I'd be grateful for the advice. >> >> Once I got the bar charts working, I would be interested in possibly >> extending this to other chart types. >> >> Regards >> >> Andrew >> >> - >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win great >> prizes >> Grand prize is a trip for two to an Open Source event anywhere in the >> world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> ___ >> Matplotlib-devel mailing list >> Matplotlib-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel >> > > -- > Michael Droettboom > Science Software Branch > Operations and Engineering Division > Space Telescope Science Institute > Opera
Re: [matplotlib-devel] Please test this patch on windows...
On Tuesday 04 November 2008 05:23:19 pm you wrote: > I attempted to improve the dependency checking in matplotlib.__init__, > using the subprocess module to silence some deprecation warnings > encountered with py2.6. I dont have access to a Windows machine, would > someone please test the attached patch or __init__.py file to see if it > works on that platform? > > Thanks, > Darren > > > Do you need it tested with Python 2.5 or 2.6? 2.4 through 2.6. I'm in the process of replacing my laptop, so I should be able to check it myself on Vista in two weeks. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] SVG clickable images
This looks great to me. I can confirm that this works on Linux as well. I think from here it's just a matter of applying the same pattern of changes to collections and images. Once that's done, I'm happy to apply the patch. And if you plan to make a lot of changes in the future, it generally pretty easy to get commit access. Just ask. Mike Andrew Stock wrote: > Hi, > > I've attached a diff file which implements the basic functionality. It > currently doesn't handle collections or draw_image, but I wanted to > get something simple working first, before expanding the scope. A > simple test program is as follows: > > from pylab import * > > f = figure() > a,b = bar([1,2], [2,5], url='http://www.bbc.co.uk/') > > a.set_url('http://www.google.com') > > f.canvas.print_figure(r'c:\test.svg') > > I'd be interested in comments / feedback on the attached before I > start to branch out into more significant changes! > > Thanks > > Andrew > > On Thu, Oct 30, 2008 at 8:02 PM, Michael Droettboom <[EMAIL PROTECTED]> wrote: > >> I realised in my earlier message, I didn't really address your initial >> request for feedback on your approach. >> >> I think the goal here should be to make the url support as pervasive as >> possible wrt both plot types and backends. >> >> Many of the high-level plotting functions (such as bar()) take a standard >> set of "Artist" keywords. In the docs, you'll often see a table like the >> one at the bottom for bar(): >> >> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.bar >> >> This support all happens automatically simply by adding a setter and getter >> to the "Artist" class. So, in Artist, simply add set_url/get_url methods >> and a private attribute to store the url. You shouldn't have to touch any >> of the high-level plotting functions to have this supported everywhere where >> it makes sense. >> >> Then, to use the url value, you'll want to store it in a GraphicsContext >> object to pass to the backend. So you'll want to add an attribute and >> getter/setter in GraphicsContextBase as well. >> >> All of the places where the front-end creates a gc and passes it to the >> backend will need to be updated (such as Artist.draw, Text.draw, perhaps >> others, do a grep for the public methods in RendererBase). Where it sets >> things like facecolor on the GraphicsContext, it should also set a url. >> >> Then, in backends where appropriate you would use the url value if present. >> You could start with SVG, and maybe someone can come along and add PDF >> support later. >> >> An additional complication for completeness is handling Collections. >> Collections store a list of graphics context information (facecolor, >> edgecolor etc.) rather than a single one. Therefore, you'll want to add >> set_urls/get_urls to Collection as well, and then deal with passing those >> values to the backend. Collections don't use a GraphicsContext class, so >> you'll need to add a new arg to draw_path_collection in all backends. >> (Refactoring this so we pass an object to the backends rather than a long >> list of arguments would be welcome to avoid needing to update multiple >> backends for these sorts of new features in the future). You will also need >> to update RendererBase._iter_collection to support iterating over URLs in >> the same way as everything else there. >> >> draw_image also doesn't use a gc, so you'll need to add an argument there. >> >> Hope that gives you a road map... Please let me know if I can help further. >> >> Mike >> >> Andrew Stock wrote: >> >>> Hi, >>> >>> I have a requirement to make clickable bar charts using the SVG output >>> (rather than html maps). >>> >>> An initial look has suggested that the following changes would be >>> required: >>> >>> backend_bases.py: Add a url property to GraphicsContextBase >>> (defaulting to None, so it's all backwards compatible) >>> axes.py: Add a url option to the bar function and pass this on to the >>> constructor of the Rectangle object >>> patches.py: Pass the url option in the constructor for the Patch >>> object to the GraphicsContextBase object created in the draw function >>> backends/backend_svg.py: Add check to _draw_svg_element for url set in >>> gc. If it is, write out SVG code for xlink. >>> >>> I can make these changes and (if people think it would be useful) >>> contribute the changes back. However, before I do this, I wanted to >>> check whether this is the right approach to take - I'm not experienced >>> with the internals of matplotlib and so if there's a better way of >>> doing it, I'd be grateful for the advice. >>> >>> Once I got the bar charts working, I would be interested in possibly >>> extending this to other chart types. >>> >>> Regards >>> >>> Andrew >>> >>> - >>> This SF.Net email is sponsored by the Moblin Your Move Developer's >>> challenge >>> Build the coolest Linux based applications with M
Re: [matplotlib-devel] SF.net SVN: matplotlib:[6363] trunk/matplotlib/examples/pylab_examples/ text_rotation_relative_to_line.py
Thanks, David. That's a much-needed feature. However, wouldn't it be simpler, API-wise, to add a new kwarg "rotation_data" (or some better name) which would be an angle in data space? (Or alternatively a boolean flag "rotation_in_data_coords"). The other advantage of that approach is that since the Text object knows what the "purpose" of the angle is, it could update the angle when the limits or figure size are changed. It looks like the heavy lifting of the calculation is already there... Cheers, Mike [EMAIL PROTECTED] wrote: > Revision: 6363 > http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6363&view=rev > Author: dmkaplan > Date: 2008-11-05 14:43:29 + (Wed, 05 Nov 2008) > > Log Message: > --- > Adding a small script that demonstrates the utility of transform_angles > method added in last > commit (from dmkaplan). > > Added Paths: > --- > trunk/matplotlib/examples/pylab_examples/text_rotation_relative_to_line.py > > Added: > trunk/matplotlib/examples/pylab_examples/text_rotation_relative_to_line.py > === > --- > trunk/matplotlib/examples/pylab_examples/text_rotation_relative_to_line.py > (rev 0) > +++ > trunk/matplotlib/examples/pylab_examples/text_rotation_relative_to_line.py > 2008-11-05 14:43:29 UTC (rev 6363) > @@ -0,0 +1,36 @@ > +#!/usr/bin/env python > +""" > +Text objects in matplotlib are normally rotated with respect to the > +screen coordinate system (i.e., 45 degrees rotation plots text along a > +line that is inbetween horizontal and vertical no matter how the axes > +are changed). However, at times one wants to rotate text with respect > +to something on the plot. In this case, the correct angle won't be > +the angle of that object in the plot coordinate system, but the angle > +that that object APPEARS in the screen coordinate system. This angle > +is found by transforming the angle from the plot to the screen > +coordinate system, as shown in the example below. > +""" > +from pylab import * > + > +# Plot diagonal line (45 degrees) > +h = plot( r_[:10], r_[:10] ) > + > +# set limits so that it no longer looks on screen to be 45 degrees > +xlim([-10,20]) > + > +# Locations to plot text > +l1 = array((1,1)) > +l2 = array((5,5)) > + > +# Rotate angle > +angle = 45 > +trans_angle = gca().transData.transform_angles(array((45,)), > + l2.reshape((1,2)))[0] > + > +# Plot text > +th1 = text(l1[0],l1[1],'text not rotated correctly',fontsize=16, > + rotation=angle) > +th2 = text(l2[0],l2[1],'text not rotated correctly',fontsize=16, > + rotation=trans_angle) > + > +show() > > > This was sent by the SourceForge.net collaborative development platform, the > world's largest Open Source development site. > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-checkins mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] transform_angles
Hi, I just wanted to send a note saying that I committed an additional method to the Transforms class that transforms angles. The basic idea is to transform an angle at a point to a new angle at the corresponding point in the transformed coordinate system. The included method is generic and should work well for almost any transform provided that the spatial scale isn't too small or too large. Much faster algorithms that would work regardless of spatial scale can be found for particular transforms, particularly affine transforms, but I haven't added these yet. I also added an example script that shows how to use this method to plot text rotated so that it aligns with a line in a figure ( text_rotation_relative_to_line.py ). I initially intended to use this method to give text objects the option to be rotated with respect to the plot coordinate system (as opposed to the screen coordinate system), but I haven't gotten around to finishing this yet. 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 ** - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] transform_angles
Darn clogged e-mail queue! ;) I see you've already addressed my question... Cheers, Mike David Kaplan wrote: > Hi, > > I just wanted to send a note saying that I committed an additional > method to the Transforms class that transforms angles. The basic idea > is to transform an angle at a point to a new angle at the corresponding > point in the transformed coordinate system. The included method is > generic and should work well for almost any transform provided that the > spatial scale isn't too small or too large. Much faster algorithms that > would work regardless of spatial scale can be found for particular > transforms, particularly affine transforms, but I haven't added these > yet. > > I also added an example script that shows how to use this method to plot > text rotated so that it aligns with a line in a figure > ( text_rotation_relative_to_line.py ). > > I initially intended to use this method to give text objects the option > to be rotated with respect to the plot coordinate system (as opposed to > the screen coordinate system), but I haven't gotten around to finishing > this yet. > > Cheers, > David > > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] transform_angles
Hi, Actually your question is a good one. One of the reasons I never finished adding an option to text objects to rotate with respect to the plot (is this the correct terminology?), not the screen, is that I wasn't sure of the best way to implement this without making it hopelessly confusing for the user. One way is to add a boolean that tells the text object whether or not the angle is with respect to screen coordinates. In this case, text_obj.get_rotation() would return the angle in whichever coordinate system is the active one based on the boolean, unless an option to get_rotation is specified that would force the angle to the screen coordinate system (this option would then be used by show methods to assure they get the correct angle for plotting on the screen). Similarly, set_rotation would set the angle in the active system. The disadvantage of this approach is that it can be pretty confusing - unless you consult the boolean, you don't know what your angle is measured relative to. Another approach would be to add a ._rotationPlot variable, as well as .get_rotationPlot and .set_rotationPlot text-object methods. In this case, using set_rotation would set the "active" angle to be the screen angle, while using set_rotationPlot would set the "active" angle to be the plot angle. The non-active angle would be set to None and show calls would test for whether or not ._rotation is none, in which case the screen angle would be calculated from the transform. In this case, get_rotation and get_rotationPlot would return angles in the respective system, regardless of which one is "active". What structure would people prefer? Another reason I never finished this is that I got confused by some of the code - there was talk of unitful and unitless rotations and coordinates. Also, I wasn't sure what to do with objects that inherit the text object class - namely, text with a dash. It didn't seem it was worth adding this non-screen rotation functionality to these objects. If anyone can point me in the right direction on these points, I will try to finish a patch for this functionality. Cheers, David On Wed, 2008-11-05 at 10:28 -0500, Michael Droettboom wrote: > Darn clogged e-mail queue! ;) > > I see you've already addressed my question... > > Cheers, > Mike > > David Kaplan wrote: > > Hi, > > > > I just wanted to send a note saying that I committed an additional > > method to the Transforms class that transforms angles. The basic idea > > is to transform an angle at a point to a new angle at the corresponding > > point in the transformed coordinate system. The included method is > > generic and should work well for almost any transform provided that the > > spatial scale isn't too small or too large. Much faster algorithms that > > would work regardless of spatial scale can be found for particular > > transforms, particularly affine transforms, but I haven't added these > > yet. > > > > I also added an example script that shows how to use this method to plot > > text rotated so that it aligns with a line in a figure > > ( text_rotation_relative_to_line.py ). > > > > I initially intended to use this method to give text objects the option > > to be rotated with respect to the plot coordinate system (as opposed to > > the screen coordinate system), but I haven't gotten around to finishing > > this yet. > > > > 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 ** - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Please test this patch on windows...
From: Darren Dale [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2008 08:48 On Tuesday 04 November 2008 05:23:19 pm you wrote: > I attempted to improve the dependency checking in matplotlib.__init__, > using the subprocess module to silence some deprecation warnings > encountered with py2.6. I dont have access to a Windows machine, would > someone please test the attached patch or __init__.py file to see if it > works on that platform? > > Thanks, > Darren > > > Do you need it tested with Python 2.5 or 2.6? 2.4 through 2.6. I'm in the process of replacing my laptop, so I should be able to check it myself on Vista in two weeks. With Python 2.5 in XP, I ran a cursory check and saw no problem initializing and using matplotlib with your __init__.py. As for the other Python versions, I'm afraid that I have neither of them installed. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] transform_angles
David Kaplan wrote: > Hi, > > Actually your question is a good one. One of the reasons I never > finished adding an option to text objects to rotate with respect to the > plot (is this the correct terminology?), not the screen, is that I > wasn't sure of the best way to implement this without making it > hopelessly confusing for the user. > > One way is to add a boolean that tells the text object whether or not > the angle is with respect to screen coordinates. In this case, > text_obj.get_rotation() would return the angle in whichever coordinate > system is the active one based on the boolean, unless an option to > get_rotation is specified that would force the angle to the screen > coordinate system (this option would then be used by show methods to > assure they get the correct angle for plotting on the screen). > Similarly, set_rotation would set the angle in the active system. The > disadvantage of this approach is that it can be pretty confusing - > unless you consult the boolean, you don't know what your angle is > measured relative to. > > Another approach would be to add a ._rotationPlot variable, as well > as .get_rotationPlot and .set_rotationPlot text-object methods. In this > case, using set_rotation would set the "active" angle to be the screen > angle, while using set_rotationPlot would set the "active" angle to be > the plot angle. The non-active angle would be set to None and show > calls would test for whether or not ._rotation is none, in which case > the screen angle would be calculated from the transform. In this case, > get_rotation and get_rotationPlot would return angles in the respective > system, regardless of which one is "active". > > What structure would people prefer? > I think the latter choice presents less confusion, particularly after hearing your arguments. It should probably be rotation_plot, just to be consistent with other getters/setters. There should probably also be a check and warning for setting rotation_plot for figure text, where it doesn't make sense, and fall back to the identity transform. > Another reason I never finished this is that I got confused by some of > the code - there was talk of unitful and unitless rotations and > coordinates. Hopefully someone else has some guidance on unit-related issues. I still don't have my head around that stuff. > Also, I wasn't sure what to do with objects that inherit > the text object class - namely, text with a dash. It didn't seem it was > worth adding this non-screen rotation functionality to these objects. > What is the argument against? It seems like this would be straightforward (at least from the outside). But I'm probably missing something. > If anyone can point me in the right direction on these points, I will > try to finish a patch for this functionality. > Thanks. Mike > Cheers, > David > > On Wed, 2008-11-05 at 10:28 -0500, Michael Droettboom wrote: > >> Darn clogged e-mail queue! ;) >> >> I see you've already addressed my question... >> >> Cheers, >> Mike >> >> David Kaplan wrote: >> >>> Hi, >>> >>> I just wanted to send a note saying that I committed an additional >>> method to the Transforms class that transforms angles. The basic idea >>> is to transform an angle at a point to a new angle at the corresponding >>> point in the transformed coordinate system. The included method is >>> generic and should work well for almost any transform provided that the >>> spatial scale isn't too small or too large. Much faster algorithms that >>> would work regardless of spatial scale can be found for particular >>> transforms, particularly affine transforms, but I haven't added these >>> yet. >>> >>> I also added an example script that shows how to use this method to plot >>> text rotated so that it aligns with a line in a figure >>> ( text_rotation_relative_to_line.py ). >>> >>> I initially intended to use this method to give text objects the option >>> to be rotated with respect to the plot coordinate system (as opposed to >>> the screen coordinate system), but I haven't gotten around to finishing >>> this yet. >>> >>> Cheers, >>> David >>> >>> >>> >>> -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Event handling example not working
John Hunter wrote: > On Wed, Oct 29, 2008 at 4:00 PM, Ryan May <[EMAIL PROTECTED]> wrote: > >> Here's probably a better question to ask than just to fix the example. >> Was it intended that the Rectangle.xy attribute disappear? I couldn't >> find it documented in API_CHANGES. It appears that there was just a >> change at some point in Michael's transforms work. If it's considered >> desirable to have it back, I'll volunteer to whip up a patch to make it >> a property. If not, let's just make sure we document this in API_CHANGES. > > I have no problem with you adding it back in as a convenience > property. Can't see the harm. Done in r6366. Also reverted the changes to the exercise, as the description still mentioned using the xy attribute. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] transform_angles
> From: Michael Droettboom [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 05, 2008 11:59 > > David Kaplan wrote: > > Hi, > > > > Actually your question is a good one. One of the reasons I never > > finished adding an option to text objects to rotate with respect to the > > plot (is this the correct terminology?), not the screen, is that I > > wasn't sure of the best way to implement this without making it > > hopelessly confusing for the user. > > > > One way is to add a boolean that tells the text object whether or not > > the angle is with respect to screen coordinates. In this case, > > text_obj.get_rotation() would return the angle in whichever coordinate > > system is the active one based on the boolean, unless an option to > > get_rotation is specified that would force the angle to the screen > > coordinate system (this option would then be used by show methods to > > assure they get the correct angle for plotting on the screen). > > Similarly, set_rotation would set the angle in the active system. The > > disadvantage of this approach is that it can be pretty confusing - > > unless you consult the boolean, you don't know what your angle is > > measured relative to. > > > > Another approach would be to add a ._rotationPlot variable, as well > > as .get_rotationPlot and .set_rotationPlot text-object methods. In this > > case, using set_rotation would set the "active" angle to be the screen > > angle, while using set_rotationPlot would set the "active" angle to be > > the plot angle. The non-active angle would be set to None and show > > calls would test for whether or not ._rotation is none, in which case > > the screen angle would be calculated from the transform. In this case, > > get_rotation and get_rotationPlot would return angles in the respective > > system, regardless of which one is "active". > > > > What structure would people prefer? > > > I think the latter choice presents less confusion, particularly after > hearing your arguments. It should probably be rotation_plot, just to be > consistent with other getters/setters. There should probably also be a > check and warning for setting rotation_plot for figure text, where it > doesn't make sense, and fall back to the identity transform. Beyond the two options of the screen coordinates and the data coordinates as the references, I believe it would be useful to allow other coordinate systems. If I wanted to diagonally watermark an entire figure with, say, "DRAFT" or "PRELIMINARY," it would be convenient to specify a rotation of +/- 45 degrees relative to the normalized (0-1) figure coordinates. The watermark would lie along the diagonal regardless of the aspect ratio. Likewise, to watermark only a subplot, one might use the normalized axes coordinates. It seems especially convenient if users could accomplish that by passing to the text object one of the predefined transforms -- like ax.transData, fig.transFigure, or ax.transAxes -- to specify the coordinate system for the rotation. Would it be possible to specify the reference system and rotation angle in a composite transform using transform machinery such as rotate_deg or rotate_deg_around? > > Another reason I never finished this is that I got confused by some of > > the code - there was talk of unitful and unitless rotations and > > coordinates. > Hopefully someone else has some guidance on unit-related issues. I > still don't have my head around that stuff. > > Also, I wasn't sure what to do with objects that inherit > > the text object class - namely, text with a dash. It didn't seem it was > > worth adding this non-screen rotation functionality to these objects. > > > What is the argument against? It seems like this would be > straightforward (at least from the outside). But I'm probably missing > something. > > If anyone can point me in the right direction on these points, I will > > try to finish a patch for this functionality. > > > Thanks. > > Mike > > Cheers, > > David > > > > On Wed, 2008-11-05 at 10:28 -0500, Michael Droettboom wrote: > > > >> Darn clogged e-mail queue! ;) > >> > >> I see you've already addressed my question... > >> > >> Cheers, > >> Mike > >> > >> David Kaplan wrote: > >> > >>> Hi, > >>> > >>> I just wanted to send a note saying that I committed an additional > >>> method to the Transforms class that transforms angles. The basic idea > >>> is to transform an angle at a point to a new angle at the corresponding > >>> point in the transformed coordinate system. The included method is > >>> generic and should work well for almost any transform provided that the > >>> spatial scale isn't too small or too large. Much faster algorithms that > >>> would work regardless of spatial scale can be found for particular > >>> transforms, particularly affine transforms, but I haven't added these > >>> yet. > >>> > >>> I also added an example script that shows how to use this method to plot > >>> text rotated
[matplotlib-devel] mlab.psd API
Hi, How much freedom would I (and my colleague) have in changing up some of the behavior/API of mlab.psd? My current issues with the function: 1) Returning one-sided or two-sided depends on whether the data is complex. I'd like that to be controlled by a keyword parameter (could take strings, such as 'two-sided' like matlab) 2) We'd like to add a parameter to control how many points are used for performing the FFT (automatic zero padding for increased plotting detail). The obvious name for this would be nfft, but this seems to conflict with the NFFT parameter. NFFT, confusingly, is used to specify the blocksize used for averaging. If we can't outright change names here, I'd love for suggestions on a good way forward. 3) Can we remove the requirement for even NFFT (blocksize)? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] mlab.psd API
On Wed, Nov 5, 2008 at 4:55 PM, Ryan May <[EMAIL PROTECTED]> wrote: > Hi, > > How much freedom would I (and my colleague) have in changing up some of > the behavior/API of mlab.psd? My current issues with the function: > > 1) Returning one-sided or two-sided depends on whether the data is > complex. I'd like that to be controlled by a keyword parameter (could > take strings, such as 'two-sided' like matlab) Sounds good > > 2) We'd like to add a parameter to control how many points are used for > performing the FFT (automatic zero padding for increased plotting > detail). The obvious name for this would be nfft, but this seems to > conflict with the NFFT parameter. NFFT, confusingly, is used to specify > the blocksize used for averaging. If we can't outright change names > here, I'd love for suggestions on a good way forward. I wrote this function a *long* time ago, so my memory is a little hazy, but I don't find the terminology confusing. The method breaks the sequence into NFFT sized chunks and does an fft on each NFFT length piece, so that is the length of the fft. Perhaps an addition pad argument if you want to zero pad the chunks? I intended to replicate the matlab function when I wrote this, and vaguely recall that I did some close comparisons on the output, but if I am misusing this parameter let me know. Some (possibly dated) matlab docs are here: http://www.mathworks.com/access/helpdesk/help/toolbox/signal/index.html?/access/helpdesk/help/toolbox/signal/periodogram.html > 3) Can we remove the requirement for even NFFT (blocksize)? Sure A while back someone on the list said that the amplitude scaling for psd was of, but I never delved into it. Something you may want to check into while you are poking around in there. http://www.nabble.com/forum/Search.jtp?forum=2906&local=y&query=psd+amplitude JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel