From: Matthieu B. <mat...@gm...> - 2007-03-12 09:08:20
|
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 <jd...@gm...>: > > On 3/9/07, Matthieu Brucher <mat...@gm...> 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 surveys-and earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > |