Isosurface plots appear 2d when used with subplot

조회 수: 13 (최근 30일)
Irem Altan
Irem Altan 2022년 6월 22일
답변: Walter Roberson 2023년 9월 25일
Hi all,
I'm trying to put together some isosurface plots using subplot. I want them to be 3d and rotatable. However, when I try using subplot together with isosurface, the plots appear 2d and are not rotatable. What am I missing? Consider the following, for instance:
[x,y,z] = meshgrid([-3:0.25:3]);
V = x.*exp(-x.^2 -y.^2 -z.^2);
for i=1:4
subplot(2,2,i);
isosurface(x,y,z,V,1e-4);
end
  댓글 수: 2
Saksham Gupta
Saksham Gupta 2022년 6월 22일
편집: Saksham Gupta 2022년 6월 22일
As per my understanding of your query, are unable to rotate subplots.
View function , when used with subplots ,can help in rotating each subplot individually.
Following code might be helpful to you:
[x,y,z] = meshgrid([-3:0.25:3]);
V = x.*exp(-x.^2 -y.^2 -z.^2);
for i=1:4
subplot(2,2,i);
isosurface(x,y,z,V,1e-4);
%Below line can be added
view(subplot(2,2,i),[10,10]);
end
Here ,[10,10] is a random elevation angle I have applied.
You may also refer to the documentation for better understanding
Irem Altan
Irem Altan 2022년 6월 22일
Thanks! This partially solves the problem. Things are now rotatable in a 3d view but the shading is still flat compared to a single plot.

댓글을 달려면 로그인하십시오.

답변 (3개)

Walter Roberson
Walter Roberson 2023년 9월 25일
MATLAB has divides graphics calls into "high level" and "low level".
"High level" calls check whether hold is on, and if not then they erase the current axes before adding the graphics.
"low level" calls never check hold, and always go ahead and add the graphics.
There are some functions such text() that are always low level. line() is low level, but plot() is high level.
There are some graphics calls that are high level or low level depending on how you call them.
When you call isosurface() without any outputs then it calls patch() to draw the surface. It does that with a calling sequence that happens to be low level for patch. So when you call isosurface that way, the surface is just added to the current graphics, and higher level graphics functions are not invoked. In particular, view(3) is not automatically called by patch() the way it might be if a high level calling sequence had been used.

William Rose
William Rose 2022년 6월 22일
I find that if I click twice on the 3D rotate icon above each plot, I am able to rotate thenm. Here is a screenshot showing your four plots, with three of them rotated.
  댓글 수: 5
Irem Altan
Irem Altan 2022년 6월 22일
Thank you for trying that as well. At this point I'm not sure if this is a bug or something else. I have reached out to tech support and will see what they say.
Yi Hui Tee
Yi Hui Tee 2023년 9월 25일
Hi, did you get any reply on this? I am facing the same problem when trying to use subplot or nexttile.

댓글을 달려면 로그인하십시오.


Saksham Gupta
Saksham Gupta 2022년 6월 22일
As per my understanding, you are telling that whole image is coming in 1 color only and not in shades as it comes for single plot.
On inputing x again as a parameter to isosurface, subplots should have the relevant shading.
For customizing colors and shading more, you should check out this documentation.
Below is the code I am using at my end :
[x,y,z] = meshgrid([-3:0.25:3]);
V = x.*exp(-x.^2 -y.^2 -z.^2);
for i=1:4
subplot(2,2,i);
isosurface(x,y,z,V,1e-4,x);
view(subplot(2,2,i),[10,10]);
end

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by