MATLAB Plot with RGB Color

16,561

I found the answer. You simply need to plot the points like this :

plot3(m(i,1) , m(i,2) , m(i,3) , 'Color' , [0.5 0.5 0] , 'Marker' , '*');

or

plot3(m(i,1) , m(i,2) , m(i,3) , 'Color' , [r g b] , 'Marker' , '*');
Share:
16,561
jeff
Author by

jeff

Updated on June 04, 2022

Comments

  • jeff
    jeff almost 2 years

    I have a matrix with sample points from different classes. Let's say they are features from 10 subjects, and there are 80 samples per subject.

    So I have a 800 x 3 matrix.

    I want to plot it using the rows as 3D points, so I use this :

    hold on;
    for i=1:length(m)
    plot3(m(i,1) , m(i,2) , m(i,3) , 'r*');
    end
    

    this works but the argument 'r*' plots all the points as red asterisks.

    But I want to plot every class as a different color. So whenever i%80==0 I need to change the color argument with an RGB vector. How can I do this?

    Thanks for any help!

  • buzjwa
    buzjwa about 10 years
    That's correct. You can find other solutions here.