3D plot with colored planes

I use
plot3(x,y,z, 'b')
box on
for plotting a 3D system. I want the faces of xy-plane, yz-plane and zx-plane to be colored by blue, red and white respectively.
Please suggest me the code. Thanks in advance.

回答(1 个)

Walter Roberson
Walter Roberson 2012-10-20

0 个投票

You can determine the axis sizes by get(gca, 'XLim') and YLim and ZLim. Using those values, you can create patch() objects that are rectangles in 3-space with the colors you want.

3 个评论

Thanks for your reply. I am not able to solve the issue. Here I am giving the code
u=linspace(0.75,1.25,51);
v=linspace(-1.25,-0.75,51);
[x,y]=meshgrid(u,v);
z1=y.*exp(x.^2);
mesh(x,y,z1)
xlabel('x'),ylabel('y'),zlabel('z')
title('3D Example with different domains')
hold on; box on;
z2=x.^2./y;
mesh(x,y,z2)
hold off
Please make my xy-plane colored only.
XL = get(gca, 'XLim');
YL = get(gca, 'YLim');
patch([XL(1), XL(2), XL(2), XL(1)], [YL(1), YL(1), YL(2), YL(2)], [0 0 0 0 0], 'FaceColor', [0 1 0]);
typo: there is a 5th 0 in your Z vector that you do not need

请先登录,再进行评论。

类别

标签

提问:

2012-10-20

评论:

LO
2021-3-7

Community Treasure Hunt

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

Start Hunting!

Translated by