Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-06 Thread Jorge Scandaliaris
Jae-Joon Lee lee.j.j...@... writes:

snip
 In recent versions, there is a separate parameter : scatterpoints. So
 check your document.
 
  ax.legend(sc, labels, scatterpoints=1)
 
 Regards,
 
 -JJ

Great! It works fine with 1.0.0

Jorge


--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-05 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:
 
snip
 Probably not directly, but I hadn't thought about that before.  For a set of 
 scatter points that are colored by values, what should the legend show?  In 
 other words, what does it *mean* for there to be a legend for points that are 
 colored in a potentially non-uniform manner?So, maybe this is desired 
 behavior 
 (but possibly by accident)?
 Thanks for your help,
 Ben Root

I thought for a moment that legend was using the color of the first point in the
set, but a quick test reveals that no matter what colormap you specify, the
marker color inside the legend is blue. BTW, I think I've found another thing
related to legend() and scatter plots: the 'numpoints' keyword argument to
legend is not respected, as showed in the example pasted below,

Jorge

---
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

data0 = np.random.rand(10,2)
data1 = np.random.rand(10,2)
data2 = np.random.rand(10,2)
data = [data0, data1, data2]

fig, ax = plt.subplots(1,1)
norm = mpl.colors.Normalize(0,len(data))
cmap = mpl.cm.afmhot

sc = []
labels = []
for i,d in enumerate(data):
sc.append(ax.scatter(d.T[0], d.T[1], c=np.ones(d.shape[0])*i,
norm=norm, cmap=cmap))
labels.append('data set ' + str(i))
ax.legend(sc, labels, numpoints=1)
plt.show()
---



--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-05 Thread Benjamin Root
On Thu, Aug 5, 2010 at 2:48 AM, Jorge Scandaliaris
jorgesmbox...@yahoo.eswrote:

 Benjamin Root ben.r...@... writes:
 
 snip
  Probably not directly, but I hadn't thought about that before.  For a set
 of
  scatter points that are colored by values, what should the legend show?
 In
  other words, what does it *mean* for there to be a legend for points that
 are
  colored in a potentially non-uniform manner?So, maybe this is desired
 behavior
  (but possibly by accident)?
  Thanks for your help,
  Ben Root

 I thought for a moment that legend was using the color of the first point
 in the
 set, but a quick test reveals that no matter what colormap you specify, the
 marker color inside the legend is blue. BTW, I think I've found another
 thing
 related to legend() and scatter plots: the 'numpoints' keyword argument to
 legend is not respected, as showed in the example pasted below,

 Jorge

 ---
 import numpy as np
 import matplotlib as mpl
 import matplotlib.pyplot as plt

 data0 = np.random.rand(10,2)
 data1 = np.random.rand(10,2)
 data2 = np.random.rand(10,2)
 data = [data0, data1, data2]

 fig, ax = plt.subplots(1,1)
 norm = mpl.colors.Normalize(0,len(data))
 cmap = mpl.cm.afmhot

 sc = []
 labels = []
 for i,d in enumerate(data):
 sc.append(ax.scatter(d.T[0], d.T[1], c=np.ones(d.shape[0])*i,
norm=norm, cmap=cmap))
labels.append('data set ' + str(i))
 ax.legend(sc, labels, numpoints=1)
 plt.show()
 ---


Yes, this was found a little while back and I believe it was fixed for v1.0.

Ben Root
--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox...@... writes:
 
 Hi,
 I am adding several scatter plots to the same axis, each having a specific
 color. When I call legend on the axis it correctly picks all scatter plots 
 with
 their symbols and labels, but it doesn't pick up the color. The example below
 demonstrates this. What I would like to do is to have in the legend the marker
 its color matching that of the set it represents. How would I do this? 

Answering my own question, I found a way to achieve what I wanted by using a
proxy artist as suggested in this thread:
http://thread.gmane.org/gmane.comp.python.matplotlib.general/20995/focus=20999

Maybe there's a better approach. I certainly would love legend to pick up on the
color used in the scatter plot by its own.

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Benjamin Root
On Wed, Aug 4, 2010 at 10:00 AM, Jorge Scandaliaris
jorgesmbox...@yahoo.eswrote:

 Jorge Scandaliaris jorgesmbox...@... writes:
 
  Hi,
  I am adding several scatter plots to the same axis, each having a
 specific
  color. When I call legend on the axis it correctly picks all scatter
 plots with
  their symbols and labels, but it doesn't pick up the color. The example
 below
  demonstrates this. What I would like to do is to have in the legend the
 marker
  its color matching that of the set it represents. How would I do this?

 Answering my own question, I found a way to achieve what I wanted by using
 a
 proxy artist as suggested in this thread:

 http://thread.gmane.org/gmane.comp.python.matplotlib.general/20995/focus=20999

 Maybe there's a better approach. I certainly would love legend to pick up
 on the
 color used in the scatter plot by its own.

 Jorge



Hmm, this definitely looks like a bug.  If I explicitly state what color I
want using the color keyword instead of using 'c' and 'norm', then
everything works properly.

Digging through the code, 'color' gets used right after the creation of the
collection object by calling the .update() function, which in turn calls the
.set_color() function which calls the set_facecolor() and set_edgecolor()
functions.  However, when using 'c' and 'norm', and having 'c' contain an
array that is the same length as the data, causes colors to be set to None
during the creation of the polygon collection.  After the collection
creation, set_array(), set_cmap() and set_norm() are called, which allows
for the scatter graph to be colored correctly upon draw.

However, I suspect that when the legend is being created, the legend uses
whatever the face/edge color that was set for the collection, which probably
isn't set yet and won't be until a draw is performed.

Ben Root
--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:

snip
 Hmm, this definitely looks like a bug.  If I explicitly state what color I 
 want
 using the color keyword instead of using 'c' and 'norm', then everything
 works properly.

I can't tell if this is a bug or not, but the trick of using a color directly is
an even simpler workaround than the one I used. Thanks.

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:

snip
 Hmm, this definitely looks like a bug. 

Should I fill a bug report about this?

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Benjamin Root
On Wed, Aug 4, 2010 at 3:01 PM, Jorge Scandaliaris
jorgesmbox...@yahoo.eswrote:

 Benjamin Root ben.r...@... writes:

 snip
  Hmm, this definitely looks like a bug.

 Should I fill a bug report about this?

 Jorge


Yes, please do, and then mention which bug report you filed to this thread.

Ben Root
--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:

snip
 
 Yes, please do, and then mention which bug report you filed to this thread.
Ben Root

Done. Bug number is 3039678 

Could this behavior be due to the fact that scatter() accepts sequences for
setting the color of each point individually? Maybe I am way off, but who 
knows...

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Benjamin Root
On Wed, Aug 4, 2010 at 3:52 PM, Jorge Scandaliaris
jorgesmbox...@yahoo.eswrote:

 Benjamin Root ben.r...@... writes:

 snip
 
  Yes, please do, and then mention which bug report you filed to this
 thread.
 Ben Root

 Done. Bug number is 3039678

 Could this behavior be due to the fact that scatter() accepts sequences for
 setting the color of each point individually? Maybe I am way off, but who
 knows...

 Jorge



Probably not directly, but I hadn't thought about that before.  For a set of
scatter points that are colored by values, what should the legend show?  In
other words, what does it *mean* for there to be a legend for points that
are colored in a potentially non-uniform manner?

So, maybe this is desired behavior (but possibly by accident)?

Thanks for your help,
Ben Root
--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users