Hi!
I'm implementing an algorithm with Matlab and I need to plot different points with different colors depending on which class each point belongs to. Here is the code I'm using:
for i=1:fil
x = data(i,:);
y = w*x';
c=strcmp(labels(i,1), classes(1,1));
if (c)
plot(y(1),y(2),'g.');
end
c=strcmp(labels(i,1), classes(2,1));
if (c)
plot(y(1),y(2),'r.');
end
c=strcmp(labels(i,1), classes(3,1));
if (c)
plot(y(1),y(2),'b.');
end
hold on
end
With this, I compare the label of each point with a defined classes vector, and select one color for each class.
But I would like it to work with an undefined number of classes that I get reading a labels file and selecting the unique labels (classes) with unique().
How could I do this, because there are only a few colours available with plot function?
Thanks in andvance.
|
|
0
|
|
|
|
Reply
|
asdf209 (154)
|
7/23/2007 12:51:15 PM |
|
Dani:
<SNIP mistaken...
> ...because there are only a few colours available with plot
function...
no, <plot> takes any rgb color you want, eg
% some data
ns=5;
z=rand(10,ns);
z=bsxfun(@plus,z,1:ns);
% some engines
% 1) one col/signal
subplot(2,1,1);
plot(z,'color',[.75,.5,.25]);
% 2) slightly more elaborate
subplot(2,1,2);
ph=plot(z);
set(ph,{'color'},num2cell(jet(ns),2));
us
|
|
0
|
|
|
|
Reply
|
us1 (8054)
|
7/23/2007 1:03:18 PM
|
|
Thank you very much.
You helped me a lot!
|
|
0
|
|
|
|
Reply
|
asdf209 (154)
|
7/24/2007 11:18:08 AM
|
|
|
2 Replies
23 Views
(page loaded in 0.04 seconds)
Similiar Articles: colorbar properties for scatter plot - comp.soft-sys.matlab ...I am trying to plot data with ... to 0.5','0.5 to1','No Data'}) This still does not solve the problem, since I now have only 5 colours, but still have twice the number ... How can I plot or display a 3D densitiy? - comp.soft-sys.matlab ...I have tried 'scatter3' using different colours ... or vector) [x,y,z]' and the output is a positive number ... Index: CSE in BG & MK 3D Data Plots: Contour 3D Data Plot ... Change plot grid line colour - comp.soft-sys.matlab... Plot area color - comp.soft-sys.matlab Change plot grid line colour ... conversion of scattered data to grid data - comp ... Since the number of plots may vary I have cre... Color Bar graph in RGB colors - comp.soft-sys.matlabHow to find Number of color pages - comp ... colorbar properties for scatter plot - comp.soft-sys.matlab ..... only 5 colours ... shading issues - comp.soft-sys.matlab Data ... Approximation of Pi - comp.soft-sys.matlabUse formatted text notes on the plot to display the number of points ... construct a B-spline approximation to given data ... to create an adequate approximation of the colours ... load file error for style setting - comp.graphics.apps.gnuplot ...... produces a plot with no lines, only pluses (+) for the > data ... the minimal number of options)? > Cheers, > Zolt=E1n set terminal postscript eps enhanced colour ... comp.soft-sys.matlab - page 16I've a plot and I wanna know the (x,y,z ... Can matlab recognize a colour by wavelength? 2 8 ... 3) where the first column is the class number and next two columns are data ... 3D model of banana - comp.soft-sys.matlab... and you just need to visualize/plot it ... an adequate approximation of the colours ... curve: [3,N] vector of curve data % r the radius of the tube % n number of ... Randomly permute a given set of numbers - comp.soft-sys.matlab ...... given ... random number to each row in a set of data and ... How to generate random number given density function ... and/or one whose colour ... drawing 3D plot using ... how to create a custom bit pattern in simulink - comp.soft-sys ...... 16 stranded on simulink. instead of using random data ... Convert signed integer to a 16-bit hex number - comp.soft ... images ... is that the same design patterns ... plot ... Matlab: How to plot data with unlimited number of colours ...programming.itags.org: Matlab question: How to plot data with unlimited number of colours, created at:Sun, 27 Apr 2008 06:42:00 GMT with 976 bytes, last updated ... 2-D line plot - MATLAB - MathWorks - MATLAB and Simulink for ...... the columns of Y versus the index of each value when Y is a real number. For complex Y, plot(Y) is ... Plot data can include NaN and inf values, which cause breaks in the lines ... 7/18/2012 11:55:04 AM
|