문제

I am using plot3 to plot a matrix such that the resultant figure shows different colors for each vector of that matrix:

plot3(Grid.x1(:,:),Grid.x2(:,:),phi(:,:))

enter image description here

How can I smooth the coloring of this plot? Thanks!

도움이 되었습니까?

해결책

You can use varycolor from FileExchange to construct and control a continuous range color spectrum. This way the transition between different lines will seem more natural and proximal lines will have similar colors.

You can read more and see examples usage here http://blogs.mathworks.com/pick/2008/08/15/colors-for-your-multi-line-plots/

Example:

[X,Y,Z] = peaks(128);

% raw plot3()
figure; plot3(X, Y, Z); 

enter image description here

% define set equal to line number
ColorSet = varycolor(128);

% smooth plot3()
figure; hold all;
set(gca, 'ColorOrder', ColorSet);
plot3(X, Y, Z); view(3); 

enter image description here

Update: For a continuous 3D plot (i.e. a surface) you can use surfl instead of plot3 and display your data as a 3-D Surface Plot (with Shading). You can additionally apply any colormap on the resulting surface, i.e. gray or ColorSet as above.

surfl(X,Y,Z);
shading interp;
colormap(gray); 

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top