[matplotlib-devel] weights in hist()
Hi, I attach a trivial patch to pass a weight argument through hist() to histogram(). Cheers, Olle--- axes.py (revision 6329) +++ axes.py (working copy) @@ -6221,13 +6221,13 @@ def hist(self, x, bins=10, range=None, normed=False, cumulative=False, bottom=None, histtype='bar', align='mid', - orientation='vertical', rwidth=None, log=False, **kwargs): + orientation='vertical', rwidth=None, log=False, weights=None, **kwargs): """ call signature:: hist(x, bins=10, range=None, normed=False, cumulative=False, bottom=None, histtype='bar', align='mid', - orientation='vertical', rwidth=None, log=False, **kwargs) + orientation='vertical', rwidth=None, log=False, weights=None, **kwargs) Compute the histogram of *x*. The return value is a tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*, @@ -6311,6 +6311,13 @@ be filtered out and only the non-empty (*n*, *bins*, *patches*) will be returned. + *weights*: array +An array of weights, the same shape as x. If normed is False, +the histogram is computed by summing the weights of the values +falling into each bin. If normed is True, the weights are +normalized, so that the integral of the density over the range +is 1. + kwargs are used to update the properties of the hist :class:`~matplotlib.patches.Rectangle` instances: @@ -6355,7 +6362,7 @@ # this will automatically overwrite bins, # so that each histogram uses the same bins m, bins = np.histogram(x[i], bins, range=range, -normed=bool(normed), new=True) +normed=bool(normed), weights=weights, new=True) n.append(m) if cumulative: - 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Native backend for Mac OS X
Michiel de Hoon wrote: > --- On Tue, 10/28/08, Christopher Barker <[EMAIL PROTECTED]> > wrote: >> I'm still curious where all this speed comes from. > At this point, most of it is coming from having complete control over > the event loop, which allows to avoid superfluous calls to draw(). well, what would be really nice is if we could figure out how to get rid of some of this superfluous calls to draw(0 in all the back-ends! I have noticed a bunch of extras in wxAgg, but had a hard time untangling it all. Also, OS-X does double buffer itself, so there may be extra work being done there is other back-ends -- essentially triple buffering. oh well. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Event handling example not working
> Neil Crighton wrote: >> I noticed on the event handling doc page: >> >> [email protected] >> >> that the draggable rectangle example doesn't work in version 0.98.3. >> The rectangle class no longer seems to have the xy property. If you >> replace the current on_press() method in the example with the code >> below it seem to work. >> >> def on_press(self, event): >> 'on button press we will see if the mouse is over us and store >> some data' >> if event.inaxes != self.rect.axes: return >> >> contains, attrd = self.rect.contains(event) >> if not contains: return >> xy = self.rect.get_x(),self.rect.get_y() >> print 'event contains', xy >> x0, y0 = xy >> self.press = x0, y0, event.xdata, event.ydata >> 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. My opinion is that randomly breaking API is always bad, and there's not much effort involved in fixing it here. On the other hand, we've already had 3 with this breakage, and no complaints up until now (and that's from our own docs :P) Thoughts? 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Event handling example not working
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. 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] SVG clickable images
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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] SVG clickable images
I think it is a good idea to add such a feature in mpl, and I guess it would better to have some general way to provide backend specific options. Actually, I have been using a modified version of mpl which enables to set the individual ID of the patches (this is only meaningful in case of the svg backend) in a very similar way that Andrew described. The purpose of setting ID is to do some postprocessing of the resulting svg file. A small post about this can be found at http://abitofpythonabitofastronomy.blogspot.com/2008/10/svg.html And my approach was also to use GCs. Although I don't quite like this approach, it seems to be the easiest way because, as far as I know, the backends in mpl does not know about the artists. I think we may introduce a new dictionary property to the GC class and also in the Artist. And modifies draw() methods of Patch and others so that it use these properties to pass any optioanl information ( "url"or "id") to the backends. But I'm not sure is if it is a good idea to expose this option (or "url" in the Andrew's original post) to the functions in the axes.py. We can just grab the return value of the "bar" command (which is a list of patches) and set some backend specific options for each patches. Regards, -JJ On Wed, Oct 29, 2008 at 6:06 PM, Andrew Stock <[EMAIL PROTECTED]> 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 > [email protected] > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > - 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
