hexbin extension

Hi all,

I've added some functionality to my copy hexbin, and I thought I'd
bounce it off folks (esp. Michael) to see if it seems like a good idea
to add it to MPL.

Here's the beginning of the docstring of the new version. What I've
added is the optional argument "C" -- inspired by scatter's "c" argument.

call signature::

  hexbin(x, y, C = None, gridsize = 100, bins = None,
         xscale = 'linear', yscale = 'linear',
         cmap=None, norm=None, vmin=None, vmax=None,
         alpha=1.0, linewidths=None, edgecolors='none'
         reduce_C_function = np.mean,
         **kwargs)

Make a hexagonal binning plot of *x* versus *y*, where *x*,
*y* are 1-D sequences of the same length, *N*. If *C* is None
(the default), this is a histogram of the number of occurences
of the observations at (x[i],y[i]).

If *C* is specified, it specifies values at the coordinate
(x[i],y[i]). These values are accumulated for each hexagonal
bin and then reduced according to *reduce_C_function*, which
defaults to numpy's mean function (np.mean). (If *C* is
specified, it must also be a 1-D sequence of the same length
as *x* and *y*.)

What do you think? I've also implemented a simple demo making use of
this functionality and an image of the output of the demo. For my own
selfish reasons, I'd love if we could stick this in 0.98.3, but I'm also
happy to hold off to get the release out the door.

-Andrew

hexbin.patch (7.19 KB)

I just fixed a small bug when bins were not filled and C was specified.
Attached is the revised version.

hexbin-revised.patch (7.67 KB)

Hi all,

I've added some functionality to my copy hexbin, and I thought I'd
bounce it off folks (esp. Michael) to see if it seems like a good idea
to add it to MPL.

Do you mean Michiel, the hexbin author? I m CC-ing him.

Here's the beginning of the docstring of the new version. What I've
added is the optional argument "C" -- inspired by scatter's "c" argument.

call signature::

  hexbin(x, y, C = None, gridsize = 100, bins = None,
         xscale = 'linear', yscale = 'linear',
         cmap=None, norm=None, vmin=None, vmax=None,
         alpha=1.0, linewidths=None, edgecolors='none'
         reduce_C_function = np.mean,
         **kwargs)

Make a hexagonal binning plot of *x* versus *y*, where *x*,
*y* are 1-D sequences of the same length, *N*. If *C* is None
(the default), this is a histogram of the number of occurences
of the observations at (x[i],y[i]).

If *C* is specified, it specifies values at the coordinate
(x[i],y[i]). These values are accumulated for each hexagonal
bin and then reduced according to *reduce_C_function*, which
defaults to numpy's mean function (np.mean). (If *C* is
specified, it must also be a 1-D sequence of the same length
as *x* and *y*.)

What do you think? I've also implemented a simple demo making use of
this functionality and an image of the output of the demo. For my own
selfish reasons, I'd love if we could stick this in 0.98.3, but I'm also
happy to hold off to get the release out the door.

The functionality looks really nice. I don't really have a problem
sneaking it in -- I'm a softie -- but we should hear from Michiel
first. I am still waiting to hear from Sandro about his sphinx problem
before trying to release anything anyhow.

JDH

···

On Sat, Jul 26, 2008 at 3:37 PM, Andrew Straw <strawman@...36...> wrote:

Andrew Straw wrote:

Hi all,

I've added some functionality to my copy hexbin, and I thought I'd
bounce it off folks (esp. Michael) to see if it seems like a good idea
to add it to MPL.

Here's the beginning of the docstring of the new version. What I've
added is the optional argument "C" -- inspired by scatter's "c" argument.

call signature::

  hexbin(x, y, C = None, gridsize = 100, bins = None,
         xscale = 'linear', yscale = 'linear',
         cmap=None, norm=None, vmin=None, vmax=None,
         alpha=1.0, linewidths=None, edgecolors='none'
         reduce_C_function = np.mean,
         **kwargs)

Make a hexagonal binning plot of *x* versus *y*, where *x*,
*y* are 1-D sequences of the same length, *N*. If *C* is None
(the default), this is a histogram of the number of occurences
of the observations at (x[i],y[i]).

If *C* is specified, it specifies values at the coordinate
(x[i],y[i]). These values are accumulated for each hexagonal
bin and then reduced according to *reduce_C_function*, which
defaults to numpy's mean function (np.mean). (If *C* is
specified, it must also be a 1-D sequence of the same length
as *x* and *y*.)

What do you think? I've also implemented a simple demo making use of
this functionality and an image of the output of the demo. For my own
selfish reasons, I'd love if we could stick this in 0.98.3, but I'm also
happy to hold off to get the release out the door.

-Andrew

Andrew,

That sounds like a nice addition, and one that does not interfere in any way with the original hexbin functionality.

Eric

Eric Firing wrote:

Andrew Straw wrote:

Hi all,

I've added some functionality to my copy hexbin, and I thought I'd
bounce it off folks (esp. Michael) to see if it seems like a good idea
to add it to MPL.

Here's the beginning of the docstring of the new version. What I've
added is the optional argument "C" -- inspired by scatter's "c" argument.

call signature::

  hexbin(x, y, C = None, gridsize = 100, bins = None,
         xscale = 'linear', yscale = 'linear',
         cmap=None, norm=None, vmin=None, vmax=None,
         alpha=1.0, linewidths=None, edgecolors='none'
         reduce_C_function = np.mean,
         **kwargs)

Make a hexagonal binning plot of *x* versus *y*, where *x*,
*y* are 1-D sequences of the same length, *N*. If *C* is None
(the default), this is a histogram of the number of occurences
of the observations at (x[i],y[i]).

If *C* is specified, it specifies values at the coordinate
(x[i],y[i]). These values are accumulated for each hexagonal
bin and then reduced according to *reduce_C_function*, which
defaults to numpy's mean function (np.mean). (If *C* is
specified, it must also be a 1-D sequence of the same length
as *x* and *y*.)

What do you think? I've also implemented a simple demo making use of
this functionality and an image of the output of the demo. For my own
selfish reasons, I'd love if we could stick this in 0.98.3, but I'm also
happy to hold off to get the release out the door.

-Andrew

Andrew,

That sounds like a nice addition, and one that does not interfere in any
way with the original hexbin functionality.

Eric

OK, with John and Eric's encouragement, I've gone ahead and checked this
into svn along with the new example in pylab
(pylab_examples/hexbin_demo2.py). I've been pounding away on it all
afternoon, and haven't found any problems, and I left the original
functionality of hexbin() untouched, so I doubt this will cause a
problem for anyone.

-Andrew

I think that this is a nice addition to the hexbin function. At first, I didn't quite understand the documentation of the "C" functionality, but the new hexbin_demo2.py example makes everything clear.

In theory, if reduce_C_function is len, then this gives the usual hexbin result. It may be a good idea to add this to the docstring to help clarify how C,reduce_C_function works.

Thanks!

--Michiel.

···

--- On Sat, 7/26/08, John Hunter <jdh2358@...149...> wrote:

From: John Hunter <jdh2358@...149...>
Subject: Re: [matplotlib-devel] hexbin extension
To: "Andrew Straw" <strawman@...36...>
Cc: "matplotlib development list" <matplotlib-devel@lists.sourceforge.net>, mjldehoon@...42...
Date: Saturday, July 26, 2008, 5:18 PM
On Sat, Jul 26, 2008 at 3:37 PM, Andrew Straw > <strawman@...36...> wrote:
> Hi all,
>
> I've added some functionality to my copy hexbin,
and I thought I'd
> bounce it off folks (esp. Michael) to see if it seems
like a good idea
> to add it to MPL.

Do you mean Michiel, the hexbin author? I m CC-ing him.

> Here's the beginning of the docstring of the new
version. What I've
> added is the optional argument "C" --
inspired by scatter's "c" argument.
>
>> call signature::
>>
>> hexbin(x, y, C = None, gridsize = 100, bins =
None,
>> xscale = 'linear', yscale =
'linear',
>> cmap=None, norm=None, vmin=None,
vmax=None,
>> alpha=1.0, linewidths=None,
edgecolors='none'
>> reduce_C_function = np.mean,
>> **kwargs)
>>
>> Make a hexagonal binning plot of *x* versus *y*,
where *x*,
>> *y* are 1-D sequences of the same length, *N*. If
*C* is None
>> (the default), this is a histogram of the number
of occurences
>> of the observations at (x[i],y[i]).
>>
>> If *C* is specified, it specifies values at the
coordinate
>> (x[i],y[i]). These values are accumulated for each
hexagonal
>> bin and then reduced according to
*reduce_C_function*, which
>> defaults to numpy's mean function (np.mean).
(If *C* is
>> specified, it must also be a 1-D sequence of the
same length
>> as *x* and *y*.)
>
> What do you think? I've also implemented a simple
demo making use of
> this functionality and an image of the output of the
demo. For my own
> selfish reasons, I'd love if we could stick this
in 0.98.3, but I'm also
> happy to hold off to get the release out the door.

The functionality looks really nice. I don't really
have a problem
sneaking it in -- I'm a softie -- but we should hear
from Michiel
first. I am still waiting to hear from Sandro about his
sphinx problem
before trying to release anything anyhow.

JDH