Plot separate data points in different colors
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I'd like to plot data of one research subject, where each data point has a different grey-scale color depending on other data of the same subject.
So, for example: x=[2 5 8 9 3 4 6 4 8 1]
% grey colors of above data points, respectively: [0.1 0.5 0.4 0.2 0.9 0.6 0.8 0.2 0.3 0.1]
plot(x,'col',<here something to have each data point have a different shade of grey>)
I did this in R before which was quite simple, because in R when you give a bigger matrix of colors as input, R recognizes immediately that each data point should have the respective color; Matlab seems to strongly require a 3 element vector as color input.
Many thanks!
0 comentarios
Respuestas (1)
Sean de Wolski
el 30 de En. de 2012
With a for-loop:
x=[2 5 8 9 3 4 6 4 8 1];
c = [0.1 0.5 0.4 0.2 0.9 0.6 0.8 0.2 0.3 0.1];
threeones = [1 1 1];
for ii = 1:numel(H)
line('xdata',ii,'ydata',x(ii),'marker','*','color',c(ii)*threeones)
end
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!