[Matplotlib-users] Comet
All, Does anyone have any code emulating Matlab's comet command? D. - 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Scaling axes not data?
Boris Barbour wrote: Eric and John, Thanks for the information. You are right that this probably would have been a premature optimisation, even if it weren't rendered useless by matplotlib using doubles internally (which I hadn't realised). The thought just occurred to me as I was writing the data-scaling part of my script. The script is intended to be somewhat interactive. Initial tests suggest that plotting or updating several subplots from memory does take a quite noticeable time (e.g. 1.2 -- 1.5 seconds for 3 subplots of 1 points) that will probably become annoying in routine use. As you indicated, basically all that time is spent within matplotlib. I'm just using standard default calls: for i in subplot subplot plot xlabel ylabel title Each of these calls seems to take roughly the same time (60--100ms). If It sounds like you have interactive mode on, in which case each pylab function redraws the figure. The solution is to use the object-oriented interface for almost everything. See the attached example. anybody has pointers on speeding things up significantly, I'm all ears. (Predefining data limits? Using lower-level commands? Use of a non-default backend?) If the suggestion above is not enough, we will need to know more about what your script looks like, the environment in which it is running (e.g., ipython? embedded in wx? straight command line? what operating system? what backend?), your constraints, and what you are trying to accomplish. The best thing would be if you could post a very short self-contained script, typically using fake random data, that shows your present approach and that illustrates the speed problem; then we can try to figure out what the bottlenecks are, and whether there are simple ways to speed up the script or to modify mpl for better speed. Eric import time import numpy as np import matplotlib.pyplot as plt npts = 1 xx = np.arange(npts) plt.ion() t0 = time.time() fig1 = plt.figure() ax = fig1.add_subplot(1,1,1) # Try again, commenting out the following three lines; # you will see no significant difference in the plotting time. ax.set_title('A title') ax.set_xlabel('This is X') ax.set_ylabel('This is Y') lines = ax.plot(xx, np.random.rand(npts)) plt.draw() t1 = time.time() print t1-t0 for ii in range(10): t0 = time.time() lines[0].set_data(xx, np.random.rand(npts)) plt.draw() t1 = time.time() print t1-t0 - 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Scaling axes not data?
Eric and John, Thanks for the information. You are right that this probably would have been a premature optimisation, even if it weren't rendered useless by matplotlib using doubles internally (which I hadn't realised). The thought just occurred to me as I was writing the data-scaling part of my script. The script is intended to be somewhat interactive. Initial tests suggest that plotting or updating several subplots from memory does take a quite noticeable time (e.g. 1.2 -- 1.5 seconds for 3 subplots of 1 points) that will probably become annoying in routine use. As you indicated, basically all that time is spent within matplotlib. I'm just using standard default calls: for i in subplot subplot plot xlabel ylabel title Each of these calls seems to take roughly the same time (60--100ms). If anybody has pointers on speeding things up significantly, I'm all ears. (Predefining data limits? Using lower-level commands? Use of a non-default backend?) Boris - 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Control space between bars
On Aug 14, 2008, at 4:51 PM, Jae-Joon Lee wrote: > Hi Mathieu, > > It seems to me that you're confused with the meaning of the transAxes. > It is a transform from the Axes coordinate to the Canvas(?) > coordinate. > As far as I can see, what you seemed to want is a transform between > Data coordinate and Axes coordinate, and that would be transScale + > transLimits (from Data to Axes). > > So, try > > trans = (ax.transScale + ax.transLimits).inverted() > # trans = ax.transLimits.inverted() will also work in this case. > > and you will get 2.0, 2.0 as you expected. > > The "transform" argument should be transAxes still. > > ax.text(valx, valy, actualcoords, transform=ax.transAxes) > > As far as your original question is concerned, I have little idea what > you are trying to do, so I'll leave that question to others. > > Regards, > > -JJ > > > On Thu, Aug 14, 2008 at 3:43 PM, Mathieu Leplatre > <[EMAIL PROTECTED]> wrote: >> I am still investigating and I am stuck at converting transAxes >> values to data. >> >> If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me >> 15.0. >> >> This would allow me to compute bar width and space, since I am able >> to >> convert inches to transAxes values. >> >> I tried many combinations of transAxes, transData, ..., >> inverse_xy_tup, xy_tup, inverted(), transform(), ... without success >> :( >> >> Any ideas please ? Hi Mathieu, I just wanted to add a little bit to Jae-Joon's example. I feel like I have to relearn the axes transformations every time I deal with them. Your email reminded me to write things down, and I thought I'd share it, in case others find it useful. Let me know if anything is wrong/ unclear. Best, -Tony = Axes Transformations Tutorial = The new transformations infrastructure is documented in the `new docs`_ (still in progress...), which talks about transformations *in general*. This document talks about transforms that are pre-defined attributes of `axes`. The following explanation is partially stolen from a mailing list reply by Michael Droettboom. In the following, data space the actual `x, y` input data coordinates axes space the axes coordinates which are `([0, 0], [1, 1])` at `([xmin,ymin], [xmax, ymax])` figure space the screen pixel coordinates. .. _new docs: http://matplotlib.sourceforge.net/doc/html/devel/ transformations.html `matplotlib.axes` transforms `transScale` scales data to account for nonlinearities (non-affine) in the axis scales, e.g. log-log and semi-log scales. For example, `transScale.transform` would convert `x = [1, 10, 100, 1000]` to `[1, 2, 3, 4]` (powers of ten) if the x-axis is logarithmically spaced. `transLimits` scales the data to the currently "zoomed" in portion of the data. `transScale + transLimits` maps data space to axes space. `transAxes` maps axes space to figure space. `transData` maps data space to the figure space. `transData` is a composite of `transScale`, `transLimits`, and `transAxes`. It's the "fast lane" between the data and the screen. Transforms example == If you want to draw a dot in the middle of the plot, you know that >>> x = y = 0.5 in axes space. Since the default transform for `matplotlib.pyplot.plot` is `transData`, you can either either change the transform of the plot operation >>> import matplotlib.pyplot as plt >>> ax = plt.subplot(111) >>> ax.plot([x], [y], 'ro', transform=ax.transAxes) Or you can transform the midpoint to data coordinates then plot them >>> trans_data2axes = ax.transScale + ax.transLimits >>> trans_axes2data = trans_data2axes.inverted() >>> mid_point = trans_axes2data.transform([x, y]) >>> x_trans, y_trans = mid_point >>> ax.plot([x_trans], [y_trans], 'gs') It's important to note that these are two **very different** approaches. The first point (red dot) above is always referenced to axes space and will remain in the center of the plot, even if you change the axes limits (try panning in interactive mode). On the other hand, the second point (green square) is referenced to the data space and will move with the data if the axes limits are changed. - 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Arrow Questions
I am trying to implement a dynamic graph in mpl, where users can drag around the nodes, and the edges follow the nodes like rubber bands. I have this working with regular edges, but I want to give the option of putting arrows on the edges. I am running into some issues with the Arrow classes. With my Text, Rectangle, and Line2D objects I can get and set their locations with methods such as get_position(), get_x(), and get_xdata() respectively. But there are no such methods for any of the Arrow classes. (By the way, it seems like these sorts of things would be in the base classes, and much more standard). What is the difference between Arrow, YAArrow, and FancyArrow anyway? (Besides drastically different scales). Some other features of the Arrow class that I would like very much are: * double headed arrows (one line with an arrow head on each end) * the ability to turn the arrow head on and off easily (Boolean parameter function) Does anyone have any ideas on how to work around these issues? Thanks, -Ben - 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Control space between bars
Hi Mathieu, It seems to me that you're confused with the meaning of the transAxes. It is a transform from the Axes coordinate to the Canvas(?) coordinate. As far as I can see, what you seemed to want is a transform between Data coordinate and Axes coordinate, and that would be transScale + transLimits (from Data to Axes). So, try trans = (ax.transScale + ax.transLimits).inverted() # trans = ax.transLimits.inverted() will also work in this case. and you will get 2.0, 2.0 as you expected. The "transform" argument should be transAxes still. ax.text(valx, valy, actualcoords, transform=ax.transAxes) As far as your original question is concerned, I have little idea what you are trying to do, so I'll leave that question to others. Regards, -JJ On Thu, Aug 14, 2008 at 3:43 PM, Mathieu Leplatre <[EMAIL PROTECTED]> wrote: > I am still investigating and I am stuck at converting transAxes values to > data. > > If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me 15.0. > > This would allow me to compute bar width and space, since I am able to > convert inches to transAxes values. > > I tried many combinations of transAxes, transData, ..., > inverse_xy_tup, xy_tup, inverted(), transform(), ... without success > :( > > Any ideas please ? > > - > import pylab as P > import matplotlib.transforms as T > > x = P.arange(5) > y = P.rand(5) * 4 > ax = P.subplot(1,1,1) > P.plot(x,y) > ax.set_ylim(0.0, 4.0) > > trans = ax.transAxes > valx = valy = 0.5 > actualcoords = "%s" % trans.transform([valx, valy]) > #Gives me [328, 240] instead of [2.0, 2.0] > > ax.text(valx, valy, actualcoords, transform=trans) > P.show() > > - > > > > On Wed, Aug 13, 2008 at 10:34 AM, Mathieu Leplatre <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> I've searched in examples and archives and could not find anything >> about manual control of space between bars. >> >> By default, the bars in the following script overlap. >> >> So I guess the behaviour is : >> specify chart width (8in) + bar width (0.8) => auto bar space >> >> And I would like to know how to do : >> specify chart width + bar space => auto bar width >> specify bar space + bar width => auto chart width (fixed margins) >> >> But I can't figure it out, especially the latter. Can >> matplotlib.transforms help me about the former ? >> >> Do you have documentation reference or some hints about that please ? >> Thanks! >> >> I am plotting a chronological bar chart like this one : >> >> #!/usr/bin/env python >> import matplotlib, pylab, numpy >> import datetime >> >> def rangedates( hourstep ): >>dates = [] >>for d in range(1,31): >>for h in range(0,24,hourstep): >>dt = datetime.datetime(2008,06,d,h) >>dates.append(dt) >>return pylab.date2num(dates) >> >> # Plot value every 12H >> abscissa = rangedates(12) >> >> barstep = abscissa[1] - abscissa[0] >> barspace = 0.5 * barstep >> barwidth = barstep - barspace >> >> fig = pylab.figure() >> ax = fig.add_subplot(111) >> fmt = matplotlib.dates.DateFormatter('%b %d') >> ax.xaxis.set_major_formatter( fmt ) >> fig.autofmt_xdate() >> >> pylab.bar( abscissa, numpy.random.randn( len(abscissa) ), >> width = barwidth) >> pylab.show() >> > > - > 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-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > - 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Control space between bars
I am still investigating and I am stuck at converting transAxes values to data. If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me 15.0. This would allow me to compute bar width and space, since I am able to convert inches to transAxes values. I tried many combinations of transAxes, transData, ..., inverse_xy_tup, xy_tup, inverted(), transform(), ... without success :( Any ideas please ? - import pylab as P import matplotlib.transforms as T x = P.arange(5) y = P.rand(5) * 4 ax = P.subplot(1,1,1) P.plot(x,y) ax.set_ylim(0.0, 4.0) trans = ax.transAxes valx = valy = 0.5 actualcoords = "%s" % trans.transform([valx, valy]) #Gives me [328, 240] instead of [2.0, 2.0] ax.text(valx, valy, actualcoords, transform=trans) P.show() - On Wed, Aug 13, 2008 at 10:34 AM, Mathieu Leplatre <[EMAIL PROTECTED]> wrote: > Hi all, > > I've searched in examples and archives and could not find anything > about manual control of space between bars. > > By default, the bars in the following script overlap. > > So I guess the behaviour is : > specify chart width (8in) + bar width (0.8) => auto bar space > > And I would like to know how to do : > specify chart width + bar space => auto bar width > specify bar space + bar width => auto chart width (fixed margins) > > But I can't figure it out, especially the latter. Can > matplotlib.transforms help me about the former ? > > Do you have documentation reference or some hints about that please ? > Thanks! > > I am plotting a chronological bar chart like this one : > > #!/usr/bin/env python > import matplotlib, pylab, numpy > import datetime > > def rangedates( hourstep ): >dates = [] >for d in range(1,31): >for h in range(0,24,hourstep): >dt = datetime.datetime(2008,06,d,h) >dates.append(dt) >return pylab.date2num(dates) > > # Plot value every 12H > abscissa = rangedates(12) > > barstep = abscissa[1] - abscissa[0] > barspace = 0.5 * barstep > barwidth = barstep - barspace > > fig = pylab.figure() > ax = fig.add_subplot(111) > fmt = matplotlib.dates.DateFormatter('%b %d') > ax.xaxis.set_major_formatter( fmt ) > fig.autofmt_xdate() > > pylab.bar( abscissa, numpy.random.randn( len(abscissa) ), > width = barwidth) > pylab.show() > - 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Feature Request: RectangleSelector BlockingInput
Hi, Sorry for the long delay - I have been on vacation. I don't use the imcrop function, but it looks fairly easy to implement using ginput. I am heading off for vacation again for another two weeks and I want to get in some of the changes I proposed a long while ago before working on this, so it might be a while, but if no one can take it on first, I can give a look next month. Cheers, David On Tue, 2008-08-05 at 19:51 -0500, John Hunter wrote: > On Tue, Aug 5, 2008 at 6:26 PM, Elfnor <[EMAIL PROTECTED]> wrote: > > > This would be really useful for implementing a user image crop function, > > similar to matlab's imcrop for example. > > David, since you are a recent matlab user and are deeply versed in the > blocking code: how hard would it be to simply provide a (mostly) > matlab compatible imcrop function, and is this something you are > interested in doing? > > JDH -- ** 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users