How to make rbg vector to use in plot

8 visualizzazioni (ultimi 30 giorni)
Jeff Lapierre
Jeff Lapierre il 25 Feb 2013
I have 3 vectors, red, green, and blue, which have been normalized to be between 0 and 1. I want to use the values of these three vectors to determine the color of each data point in a plot ie:
figure
color = [red(first(1):last(1)) green(first(1):last(1)) blue(first(1):last(1))]; plot(time(first(1):last(1)),data(first(1):last(1)),'Color',color)
The size of 'color' is 156078x3, which is the same length as data, however matlab is still saying:
_Error using plot
Color value must be a 3 element numeric vector
Error in plot_lma_08_14_21_42_26/plot_inter (line 704)
plot(time(first(1):last(1)),data(first(1):last(1)),'Color',color)_
color(1:4,1:3)
ans =
0.9961 0.5352 0.4336
0.9961 0.5625 0.3789
0.9961 0.8477 0.3984
0.8320 0.9961 0.7266
'color' is a numeric vector and seems to be the right size so I don't know what is wrong. Can someone please help me?

Risposte (1)

Image Analyst
Image Analyst il 25 Feb 2013
plot() can only plot in one color at a time, so in
,'Color',color
color must be a 1 by 3 array of numbers in the range 0-1. If you want different colors for each data point, use scatter().

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by