nD plotting

Matthew Auger wrote the following on 08/13/2007 11:15 AM:

I'm trying to make high-dimensionality scatter plots, but I've run into a
couple of issues. I'm using scatter() but including both edge and face
color mapping; I doubt this will provide a meaningful display, but I'd
like to try it and see.... Unfortunately, passing data arrays to facecolor
and edgecolor does *not* map the data arrays to colors--instead I get
gray edges and/or faces. As a side note, none of the 'usual' keyword
shortcuts (ec, fc, lw for example) work with scatter().

Does the following demonstrate the issue?

···

--------------
import pylab
x = [a for a in range(10)]
y = [a**2 for a in range(10)]
s = [a**3 for a in range(10)]
c = x
ec = c[:]
ec.reverse()

a = pylab.scatter(x,y,s,
                  facecolor=pylab.cm.jet(c),
                  edgecolor=pylab.cm.jet(ec))

print a._facecolors
print a._edgecolors

pylab.show()
-------------

So we create a scatter plot with different sizes, facecolors, and
edgecolors. The collection clearly has the facecolors/edgecolors
stored. However, resulting image does not show the different
facecolors/edgecolors. Each circle is given the default
facecolor/edgecolor (as axes.py indicates it should)...but It seems
like something is not getting updated. Comments anyone? ...seems
like a bug at first glance...

Confirmed with version 0.90.1.

This demonstrates the *solution*--the problem is that scatter() does not automagically perform color mapping for the edge and face colors. Perhaps this is a 'feature', but if so (or even if not) maybe the documentation should be clarified (I figured 'c' and 'color' were equivalent, like other mpl functions, but this is NOT the case for scatter; none of the 'color' kwargs are automatically mapped).

···

On Tue, 14 Aug 2007, Joe Shmoe wrote:

Matthew Auger wrote the following on 08/13/2007 11:15 AM:

I'm trying to make high-dimensionality scatter plots, but I've run into a
couple of issues. I'm using scatter() but including both edge and face
color mapping; I doubt this will provide a meaningful display, but I'd
like to try it and see.... Unfortunately, passing data arrays to facecolor
and edgecolor does *not* map the data arrays to colors--instead I get
gray edges and/or faces. As a side note, none of the 'usual' keyword
shortcuts (ec, fc, lw for example) work with scatter().

Does the following demonstrate the issue?

--------------
import pylab
x = [a for a in range(10)]
y = [a**2 for a in range(10)]
s = [a**3 for a in range(10)]
c = x
ec = c[:]
ec.reverse()

a = pylab.scatter(x,y,s,
                 facecolor=pylab.cm.jet(c),
                 edgecolor=pylab.cm.jet(ec))

print a._facecolors
print a._edgecolors

pylab.show()
-------------

So we create a scatter plot with different sizes, facecolors, and
edgecolors. The collection clearly has the facecolors/edgecolors
stored. However, resulting image does not show the different
facecolors/edgecolors. Each circle is given the default
facecolor/edgecolor (as axes.py indicates it should)...but It seems
like something is not getting updated. Comments anyone? ...seems
like a bug at first glance...

Confirmed with version 0.90.1.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Indeed...and I wish the behavior was more like other mpl functions.
Either way, passing my list through a colormap did not solve the issue
(for me). If I call:

scatter(x,y,s,c)

then I get a scatter plot where the points are different sizes and
colors. Without specifying the keyword 'edgecolor', it is not
possible to have varying edge colors. For consistency, I set the
facecolors through a keyword as well. So, I would like to be able to
make the following command:

scatter(x,y,s, facecolor=cm.jet(c), edgecolor=cm.jet(ec))

where, as noted, we must manually map the colors when specifying via
keywords. However, when I run the above command, I do not get a
scatter plot with varying sizes, colors, and edgecolors. Instead, I
get varying sizes, all points with 'b' as a facecolor, and all points
with 'k' as an edgecolor.

I've tried to figure this out...comments are requested...

I am looking at axes.py/scatter now....

When I make the above statement, c takes on its default value (which
is 'b'). The function sees that c is string like and converts it to a
rgba_list. Since 'faceted' defaults to True, edgecolors=None.

Now we go through and create the *PolyCollection. For 'facecolors' we
pass in 'b'...and for 'edgecolors' we pass in None. After creation,
collection.update(kwargs) is called.

As I understand it, this is what *should* happen when the update
method is called: The collection should take my keywords 'facecolor'
and 'edgecolor' and assign them to self._facecolors and
self._edgecolors. This does occur (as my first reply demonstrated).
It seems what should *also* happen is that the facecolors/edgecolors
of the points should be updated...but this does not occur.

Do you (or does anybody) have a working, simple example where the
faces/edges are both varying for a scatter plot? Perhaps I've missed
something obvious.

···

On 8/14/07, Matthew Auger <mauger@...1477...> wrote:

This demonstrates the *solution*--the problem is that scatter() does not
automagically perform color mapping for the edge and face colors.

One thing you have missed is the behavior of pylab.cm.jet. If you pass it an integer array, it treats the integers as indices into the default jet colormap, with 256 colors. If you pass it a float array, the floats must be scaled from 0 to 1, in which case you will get scaled values from the colormap.

I am sure there is more to this story, and probably some improvements needed in scatter and/or its documentation, but this is all I have time for at the moment.

Eric

Joe Shmoe wrote:

···

On 8/14/07, Matthew Auger <mauger@...1477...> wrote:

This demonstrates the *solution*--the problem is that scatter() does not
automagically perform color mapping for the edge and face colors.

Indeed...and I wish the behavior was more like other mpl functions.
Either way, passing my list through a colormap did not solve the issue
(for me). If I call:

scatter(x,y,s,c)

then I get a scatter plot where the points are different sizes and
colors. Without specifying the keyword 'edgecolor', it is not
possible to have varying edge colors. For consistency, I set the
facecolors through a keyword as well. So, I would like to be able to
make the following command:

scatter(x,y,s, facecolor=cm.jet(c), edgecolor=cm.jet(ec))

where, as noted, we must manually map the colors when specifying via
keywords. However, when I run the above command, I do not get a
scatter plot with varying sizes, colors, and edgecolors. Instead, I
get varying sizes, all points with 'b' as a facecolor, and all points
with 'k' as an edgecolor.

I've tried to figure this out...comments are requested...

I am looking at axes.py/scatter now....

When I make the above statement, c takes on its default value (which
is 'b'). The function sees that c is string like and converts it to a
rgba_list. Since 'faceted' defaults to True, edgecolors=None.

Now we go through and create the *PolyCollection. For 'facecolors' we
pass in 'b'...and for 'edgecolors' we pass in None. After creation,
collection.update(kwargs) is called.

As I understand it, this is what *should* happen when the update
method is called: The collection should take my keywords 'facecolor'
and 'edgecolor' and assign them to self._facecolors and
self._edgecolors. This does occur (as my first reply demonstrated).
It seems what should *also* happen is that the facecolors/edgecolors
of the points should be updated...but this does not occur.

Do you (or does anybody) have a working, simple example where the
faces/edges are both varying for a scatter plot? Perhaps I've missed
something obvious.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users