stem3 color variation / alternatives ?
2 次查看(过去 30 天)
显示 更早的评论
[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
2014-11-28
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)
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!