Reid Hansen
Reid Hansen

Reputation: 23

Matlab Scatter Plot Color Scheme

Good Evening,
I'm still new to matlab (and stack overflow)
I've got a set of data that I want to plot with the "plot" command.
I have 9 days of data that I would like to plot.
Preferably with each day having it's own color.
But after looking online, Matlab only has 8 pre-built colors, 2 of them being white and yellow. (and yellow doesn't show up too well on a white background)
I've looked online and tried passing the "color" command with a RGB combo, but that breaks as well.

I've had to resort to changing the first and last day to a different shape, that works now, but it isn't presentation worthy. The first data point and the last data point need their own color.
The +,X,* just represent the number of the launch that occurred that day.

Attached is my script.

Many thanks in advance. Reid

%--------------------------------------------------------  
% define Model_Point array  
%--------------------------------------------------------   
Point_model = [0.0112, 0.2147, 0.295, 0.0356, 0.0912, 0, 0, 0.0738, 0.2143, 0.0798, 0.0169, 0.089, 0, 0, 0.1644, 0.065, 0.2271, 0.0727];  

%---------------------------------------------------------  
% define Model_Neighborhood array  
%---------------------------------------------------------  
Neighborhood_model = [0.0573343, 0.422929, 0.609221, 0.667158, 0.820867, 0.580356, 0.487199, 0.56226, 0.325294, 0.249353, 0.184591, 0.214189, 0.159878, 1.07934, 2.48956, 0.26571, 0.470282, 0.221556];

%---------------------------------------------------------  
%plotting  
%---------------------------------------------------------  
plot(Point_model(1), Neighborhood_model(1), 'rp')  
hold on;  
plot(Point_model(2), Neighborhood_model(2), 'r+')  
plot(Point_model(3), Neighborhood_model(3), 'rx')  
plot(Point_model(4), Neighborhood_model(4), 'm+')  
plot(Point_model(5), Neighborhood_model(5), 'mx')  
plot(Point_model(6), Neighborhood_model(6), 'y+')  
plot(Point_model(7), Neighborhood_model(7), 'yx')  
plot(Point_model(8), Neighborhood_model(8), 'y*')  
plot(Point_model(9), Neighborhood_model(9), 'g+')  
plot(Point_model(10), Neighborhood_model(10), 'gx')  
plot(Point_model(11), Neighborhood_model(11), 'c+')  
plot(Point_model(12), Neighborhood_model(12), 'cx')  
plot(Point_model(13), Neighborhood_model(13), 'b+')  
plot(Point_model(14), Neighborhood_model(14), 'bx')  
plot(Point_model(15), Neighborhood_model(15), 'b*')  
plot(Point_model(16), Neighborhood_model(16), 'k+')  
plot(Point_model(17), Neighborhood_model(17), 'kx')  
plot(Point_model(18), Neighborhood_model(18), 'kp')  

hold on;  
plot(x, y, 'b-')  
xlabel('ILW [mm]');  
ylabel('ILW [mm]');  
title('Plot')
hold on;  
legend('y20150122','y20150129A','y20150129B','y20150211A','y20150211B','y20150313A','y20150313B','y20150313C','y20150317A','y20150317B','y20150320A','y20150320B','y20150325A','y20150325B','y20150325C','y20150326A','y20150326B','y20150423','Location','eastoutside')

Thank you again!

Upvotes: 2

Views: 836

Answers (2)

gariepy
gariepy

Reputation: 3674

Try

plot(x,y,'x','Color', [.9 .8 .7])  %% use your [r g b] values in the brackets

EDIT: note that most MATLAB arguments to plot commands start with a capital letter

EDIT2: note that you can use a marker string like 'x' or 'o' without using a color.

Upvotes: 0

frghost1
frghost1

Reputation: 11

instead of picking rgb values, you can use built in a matlab colormap that generates N colors within a colormap space.

For example, if you use clr = jet(18), you will get a 18x3 matrix of rbg values moving through the jet color space (red to blue).

For publications, red and blue will map to the same visual grayscale, so you might want to try a package like varycolor which you can find on mathworks website. This gives you a unique rgb colormap that also does not map to the same grayscale value if you print black and white.

also see help colormap for other options

Upvotes: 1

Related Questions