stem3 color variation / alternatives ?

[X,Y]=meshgrid(1:1:1000,1:100);
Z = noise; %Noise is a 100x1000 matrix%
stem3(X,Y,Z);
My question is : how to vary color of Z ? I mean, I want to vary color (important - randomly ), as without color variation, there is no way to look at floor of this data. Attached is the stem3 plot with single color.How do I vary color of data for every different value of Y ? Thanks.

답변 (1개)

Star Strider
Star Strider 2014년 11월 28일

0 개 추천

You can change the stem colour by specifying 'Color' and the marker face colour with 'MarkerFaceColor'. To change them to each have different colours, you have to plot them individually in a loop, changing the colour with each iteration for each data point.
This works with R2014b and earlier, but it is relatively easy to change it to use R2014b handle syntax:
s = [1.35846579 -0.010903161 -1.35846579 -2.466e-05
2.71686196 -0.033203464 -2.71686196 -4.506e-05
4.07514048 -0.066900126 -4.07514048 -6.485e-05
5.43325424 -0.111991957 -5.43325424 -8.391e-05
6.79115438 -0.168477371 -6.79115438 -0.000102];
cr = colormap(jet);
figure(1)
hold on
for k1 = 1:size(s,1)
randcol = randi(size(cr,1));
stem3(s(k1,1), s(k1,2), s(k1,3), 'fill', 'MarkerFaceColor', cr(randcol,:))
end
hold off
grid on
view(-30, 30)

카테고리

도움말 센터File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

제품

태그

질문:

2014년 11월 28일

답변:

2014년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by