Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Matthieu Brucher <matthieu.brucher@gm...>  20070309 09:35:08
Attachments:
Message as HTML

Hi, I'm trying to plot a set of points, each point having a different color. For the moment, I'm trying to do something like that : for indice in range(0, points.shape[0]): pl.plot(points[indice, 0], points[indice, 1], 'o', c = colours[indice,:], hold = True) where points is a numpy array of point and colours is a numpy array of dimension (points.shape[0], 3) With Matlab, something like this would function, but not in matplotlib, it tells me : ValueError: need more than 0 values to unpack I am missing something ? Matthieu 
From: John Hunter <jdh2358@gm...>  20070309 14:10:27

On 3/9/07, Matthieu Brucher <matthieu.brucher@...> wrote: > Hi, > > I'm trying to plot a set of points, each point having a different color. > For the moment, I'm trying to do something like that : > > for indice in range(0, points.shape[0]): > pl.plot(points[indice, 0], points[indice, 1], 'o', c = > colours[indice,:], hold = True) > > where points is a numpy array of point and colours is a numpy array of > dimension (points.shape[0], 3) > > With Matlab, something like this would function, but not in matplotlib, it > tells me : > ValueError: need more than 0 values to unpack Complete examples always help ince we have no way of knowing what the points data structures look like, but I'll hazard a gues. The x and y arguments to "plot" need to be sequences. Ie, something like plot([0.5], [0.5], 'ro') It can be inefficient to plot many separate points this way  if you have a lot of points, use a matplotlib.collections.RegularPolyCollection or scatter. JDH 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070309 14:19:09
Attachments:
Message as HTML

> > Complete examples always help ince we have no way of knowing what the > points data structures look like, but I'll hazard a gues. The x and y > arguments to "plot" need to be sequences. Ie, something like > > plot([0.5], [0.5], 'ro') > > It can be inefficient to plot many separate points this way  if you > have a lot of points, use a > matplotlib.collections.RegularPolyCollection or scatter. > Thank you for your answer :) OK, I'll try to wrap them :. The best solution would indeed be to paint them all at once, but I didn't manage to do that, even when I looked in the scatter_demo2 example :( What I have is a set of points in a numpy.array  for instance size (2000, 2) . What I have as well is a nump.array of size (2000, 3). How can I make plot understand that each line of the set points must be painted with the corresponding line in the colour array ? Matthieu 
From: John Hunter <jdh2358@gm...>  20070309 14:30:44

On 3/9/07, Matthieu Brucher <matthieu.brucher@...> wrote: > What I have is a set of points in a numpy.array  for instance size (2000, > 2) . What I have as well is a nump.array of size (2000, 3). How can I make > plot understand that each line of the set points must be painted with the > corresponding line in the colour array ? You'll probably want to use a regular poly collection, as in the example below. Your array of facecolors can pretty much be whatever you want: from pylab import figure, nx, show, cm from matplotlib.collections import RegularPolyCollection fig = figure() ax = fig.add_subplot(111) offsets = nx.mlab.rand(20,2) facecolors = [cm.jet(x) for x in nx.mlab.rand(20)] black = (0,0,0,1) collection = RegularPolyCollection( fig.dpi, numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors = facecolors, edgecolors = (black,), linewidths = (1,), offsets = offsets, transOffset = ax.transData, ) ax.add_collection(collection) show() > Matthieu > >  > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveysand earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > > 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070309 14:51:40
Attachments:
Message as HTML

Thank you, I think thatthis will solve my problem :) I didn't know this class existed. Matthieu 2007/3/9, John Hunter <jdh2358@...>: > > On 3/9/07, Matthieu Brucher <matthieu.brucher@...> wrote: > > > What I have is a set of points in a numpy.array  for instance size > (2000, > > 2) . What I have as well is a nump.array of size (2000, 3). How can I > make > > plot understand that each line of the set points must be painted with > the > > corresponding line in the colour array ? > > You'll probably want to use a regular poly collection, as in the > example below. Your array of facecolors can pretty much be whatever > you want: > > from pylab import figure, nx, show, cm > from matplotlib.collections import RegularPolyCollection > > > fig = figure() > ax = fig.add_subplot(111) > > offsets = nx.mlab.rand(20,2) > facecolors = [cm.jet(x) for x in nx.mlab.rand(20)] > black = (0,0,0,1) > > collection = RegularPolyCollection( > fig.dpi, > numsides=5, # a pentagon > rotation=0, > sizes=(50,), > facecolors = facecolors, > edgecolors = (black,), > linewidths = (1,), > offsets = offsets, > transOffset = ax.transData, > ) > > ax.add_collection(collection) > > show() > > > > > > > > > Matthieu > > > > >  > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > > opinions on IT & business topics through brief surveysand earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Matplotlibusers mailing list > > Matplotlibusers@... > > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > > > > > 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070312 09:08:20
Attachments:
Message as HTML

I manage to do what I wanted to do, it was not that easy  the colours were in an array I had to transform into an array of tuples, the autoscale did not function, I had to put in the fig.subplot the correct xlim and ylim , but now it works like a charm. Many thanks. Matthieu 2007/3/9, John Hunter <jdh2358@...>: > > On 3/9/07, Matthieu Brucher <matthieu.brucher@...> wrote: > > > What I have is a set of points in a numpy.array  for instance size > (2000, > > 2) . What I have as well is a nump.array of size (2000, 3). How can I > make > > plot understand that each line of the set points must be painted with > the > > corresponding line in the colour array ? > > You'll probably want to use a regular poly collection, as in the > example below. Your array of facecolors can pretty much be whatever > you want: > > from pylab import figure, nx, show, cm > from matplotlib.collections import RegularPolyCollection > > > fig = figure() > ax = fig.add_subplot(111) > > offsets = nx.mlab.rand(20,2) > facecolors = [cm.jet(x) for x in nx.mlab.rand(20)] > black = (0,0,0,1) > > collection = RegularPolyCollection( > fig.dpi, > numsides=5, # a pentagon > rotation=0, > sizes=(50,), > facecolors = facecolors, > edgecolors = (black,), > linewidths = (1,), > offsets = offsets, > transOffset = ax.transData, > ) > > ax.add_collection(collection) > > show() > > > > > > > > > Matthieu > > > > >  > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > > opinions on IT & business topics through brief surveysand earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Matplotlibusers mailing list > > Matplotlibusers@... > > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > > > > > 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070312 09:45:42
Attachments:
Message as HTML

OK, I'm trying to the same but in 3D, and there, no documentaion. I tried to launch axes3d.py to see exactly what I can do, but the example file does not work. For instance, Axes3D takes two parameters for method __init__ and only one is provided. Did someone test it ? I'm trying to use collection as well, but for once I prefer MatLab simplicity here, it's way to complicated, some arguments must be zipped, other are passed not in the collection, but when the collection is added to the subplot, ... Is there a simple and clear way to do 3D plotting with collections ? Matthieu 2007/3/12, Matthieu Brucher <matthieu.brucher@...>: > > I manage to do what I wanted to do, it was not that easy  the colours > were in an array I had to transform into an array of tuples, the autoscale > did not function, I had to put in the fig.subplot the correct xlim and > ylim , but now it works like a charm. > Many thanks. > > Matthieu > > 2007/3/9, John Hunter <jdh2358@...>: > > > > On 3/9/07, Matthieu Brucher <matthieu.brucher@...> wrote: > > > > > What I have is a set of points in a numpy.array  for instance size > > (2000, > > > 2) . What I have as well is a nump.array of size (2000, 3). How can I > > make > > > plot understand that each line of the set points must be painted with > > the > > > corresponding line in the colour array ? > > > > You'll probably want to use a regular poly collection, as in the > > example below. Your array of facecolors can pretty much be whatever > > you want: > > > > from pylab import figure, nx, show, cm > > from matplotlib.collections import RegularPolyCollection > > > > > > fig = figure() > > ax = fig.add_subplot(111) > > > > offsets = nx.mlab.rand(20,2) > > facecolors = [cm.jet(x) for x in nx.mlab.rand(20)] > > black = (0,0,0,1) > > > > collection = RegularPolyCollection( > > fig.dpi, > > numsides=5, # a pentagon > > rotation=0, > > sizes=(50,), > > facecolors = facecolors, > > edgecolors = (black,), > > linewidths = (1,), > > offsets = offsets, > > transOffset = ax.transData, > > ) > > > > ax.add_collection (collection) > > > > show() > > > > > > > > > > > > > > > > > Matthieu > > > > > > > >  > > > Take Surveys. Earn Cash. Influence the Future of IT > > > Join SourceForge.net's Techsay panel and you'll get the chance to > > share your > > > opinions on IT & business topics through brief surveysand earn cash > > > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > _______________________________________________ > > > Matplotlibusers mailing list > > > Matplotlibusers@... > > > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > > > > > > > > > > 
From: Eric Firing <efiring@ha...>  20070312 17:53:21

Matthieu Brucher wrote: > OK, I'm trying to the same but in 3D, and there, no documentaion. > I tried to launch axes3d.py to see exactly what I can do, but the > example file does not work. For instance, Axes3D takes two parameters > for method __init__ and only one is provided. Did someone test it ? > I'm trying to use collection as well, but for once I prefer MatLab > simplicity here, it's way to complicated, some arguments must be zipped, > other are passed not in the collection, but when the collection is added > to the subplot, ... > Is there a simple and clear way to do 3D plotting with collections ? There may be, but all 3D plotting is shaky right now. The 3D code is essentially unmaintained and unsupported. Eric 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070312 18:00:52
Attachments:
Message as HTML

> > There may be, but all 3D plotting is shaky right now. The 3D code is > essentially unmaintained and unsupported. > > Eric > Sad to hear this, I hope someone will enhance it :) Matthieu 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070327 15:28:54
Attachments:
Message as HTML

Hi, I tried to dig into the 3D code, and in fact, it is RegularPolyCollection that seems to be incompatible with Axes3D. Axes3D uses _verts to create z values, and it crashes when trying to figure out how to display it (art3d.pylines 208221). I don't know enough to correct it. But I have another idea, but I suppose some had it before. In the plot, scatter, ... code, only one colour can be used, it is tested upon, so my question will be, why not enhancing the test to allow colors for each point ? it would be a sequence of the same size as x or y, but with rgba value, or tuples, ... Matthieu P.S. : if I had more time, I would try to solve the problem, but at the moment, I can't :( 2007/3/12, Eric Firing <efiring@...>: > > Matthieu Brucher wrote: > > OK, I'm trying to the same but in 3D, and there, no documentaion. > > I tried to launch axes3d.py to see exactly what I can do, but the > > example file does not work. For instance, Axes3D takes two parameters > > for method __init__ and only one is provided. Did someone test it ? > > I'm trying to use collection as well, but for once I prefer MatLab > > simplicity here, it's way to complicated, some arguments must be zipped, > > other are passed not in the collection, but when the collection is added > > to the subplot, ... > > Is there a simple and clear way to do 3D plotting with collections ? > > There may be, but all 3D plotting is shaky right now. The 3D code is > essentially unmaintained and unsupported. > > Eric > 
From: Eric Firing <efiring@ha...>  20070312 18:07:49

Matthieu Brucher wrote: > I manage to do what I wanted to do, it was not that easy  the colours > were in an array I had to transform into an array of tuples, the > autoscale did not function, I had to put in the fig.subplot the correct > xlim and ylim , but now it works like a charm. > Many thanks. What version of mpl are you using? In recent versions, the collections should accept 2D numpy arrays as well as any sequence of tuples (and several other possibilities). Autoscaling does not work well with arbitrary collections because there is a chickenandegg problem: a collection member may be drawn in pixels or other physical units, in which case its size in data units cannot be determined until it is drawn with a given xlim and ylim (and sometimes dpi). Eric 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070312 18:19:59
Attachments:
Message as HTML

> > What version of mpl are you using? The latest, I compiled it from the source as FC5 has a very old version  can't update myself the distribution  In recent versions, the collections should accept 2D numpy arrays as > well as any sequence of tuples (and several other possibilities). For 2D plots, numpy arrays is accepted  but not for colors, it tells me there is a problem with tuples, I do not remember exactly, but I can check the error tomorrow . For 3D plots, the offsets must be special, I suppose, as the array must be iterated on with a zip, I don't know why there is this need, but I didn't write it :) This difference in format is akward : And the fact that the example file cannot be executed is still stranger. Autoscaling does not work well with arbitrary collections because there > is a chickenandegg problem: a collection member may be drawn in pixels > or other physical units, in which case its size in data units cannot be > determined until it is drawn with a given xlim and ylim (and sometimes > dpi). That is not my worst problem, I imposed the limits and it works now like a charm :) Matthieu 
From: Matthieu Brucher <matthieu.brucher@gm...>  20070319 09:53:41
Attachments:
Message as HTML

Hi, I tried it again, and now it works like charm with numpy arrays. I do not understand why it did not work before, but it works now, it's all that matters :) But 3D is another problem... Matthieu 2007/3/14, Eric Firing <efiring@...>: > > Matthieu Brucher wrote: > > What version of mpl are you using? > > > > > > > > The latest, I compiled it from the source as FC5 has a very old version > >  can't update myself the distribution  > > > > > > In recent versions, the collections should accept 2D numpy arrays as > > well as any sequence of tuples (and several other possibilities). > > > > > > > > For 2D plots, numpy arrays is accepted  but not for colors, it tells me > > there is a problem with tuples, I do not remember exactly, but I can > > check the error tomorrow . > > Mathieu, > > Did you come up with a minimal example of this? If so, please send it > to me directly. I would like to follow up on it. > > Thanks. > > Eric > 