help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scatter-plotting by color


From: Paul Kienzle
Subject: Re: scatter-plotting by color
Date: Thu, 20 Dec 2001 12:22:55 -0500

AFAIK, gnuplot doesn't have fine grained color control, so you might have
trouble with this.  I don't know about plplot.

Here's a possibility:

        # generate some data
        x = rand(30,1);
        y = rand(size(x));
        C = rand(size(x));
        # define a colormap that uses different colors for all its points
        map=hsv(64);
        map(1,:)=[1,1,1];
        colormap(map);
        # convert your x,y coordinates to image coordinates
        xi = 1+round((x-min(x))/(max(x)-min(x))*399);
        yi = 1+round((y-min(y))/(max(y)-min(y))*399);
        # use implicit sparse->full conversion to build an image array
        # use conv2 to spread spread the points out a bit (ones(5) makes
        # them into a 5x5 square, but you could easily define another shape
        matrix = conv2(sparse(xi,yi,C,400,400),ones(5),'same');
        # if we had a proper image viewer, we could define the x and y
        # axes as well:
        xstep = linspace(min(x),max(x),400);
        ystep = linspace(min(y),max(y),400);
        imagesc(xstep,ystep,matrix);
        # or if you have epsTk:
        eopen("scatter.ps");
        eglobpar;
        
eaxes([min(x),(max(x)-min(x))/10,max(x)],[min(y),(max(y)-min(y))/10,max(y)]);
        eimagesc(matrix,map,'e');
        eclose
        eview

Paul Kienzle
address@hidden

On Wed, Dec 19, 2001 at 07:24:59PM -0500, John Day wrote:
> I have a file of 3-tuples (X,Y,C), where C is an integer 1-16, which I want 
> to scatter-plot, X by Y with C determining the color of the plotted dots.
> 
> Does anyone know or have a ready-made function to do this? I don't care 
> what the colors are as long as they are unique for each value of C. 
> Different-shaped dots will do if we run out of colors.
> 
> Thanks,
> John Day
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]