3D spherical plot is cut off by the edges of the graphing window

조회 수: 14 (최근 30일)
I have a 3D spherical graph that draws a sphere (Earth) and points along the sphere. However, when I zoom in on the sphere, the edges of the plot window cut off the sides of the image. See the screenshots below:
I've tried changing the camera perspective, setting the axes so they are outside of the window (so the sphere would intersect with the boundaries of the axis when it is outside of the window, etc.) but nothing has worked so far. In essence, I need some way to create a spherical enviorment so when I zoom in on the sphere, the walls of the plot consisently or spherically remove the textures around the sphere, rather than making straight, flat cuts through the sphere.
The code for the sphere generation is shown below:
[X,Y,Z] = ellipsoid(0, 0, 0, rE, rE, rE, 100);
globe = surf(X,Y,Z);
Please let me know if you have any ideas! Thank you so much!

채택된 답변

Justus Quint Von Lengerke
Justus Quint Von Lengerke 2023년 6월 12일
Figured it out! Under axes properties, there is a "clipping" perameter -- set that to "off" and it works!
  댓글 수: 1
Les Beckham
Les Beckham 2023년 6월 12일
Oh, good. What does the zoomed in figure look like with that parameter changed (just curious)?

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

추가 답변 (1개)

Les Beckham
Les Beckham 2023년 6월 12일
This doesn't work if you want to be able to interactively zoom in on a region, but if you have in mind a specific range of X, Y, Z that you want to examine, something like this might work.
Also note that your example code doesn't draw the pretty globe with continents and oceans, just a ball.
rE = 6.378e6; % meters
[X,Y,Z] = ellipsoid(0, 0, 0, rE, rE, rE, 100);
globe = surf(X,Y,Z);
axis equal
xlabel 'X'
ylabel 'Y'
zlabel 'Z'
range = 1000*5280*0.3048; % 1000 miles converted to meters
idx = (X < -range) & (Y < -range) & (Z > range);
X(~idx) = nan;
Y(~idx) = nan;
Z(~idx) = nan;
surf(X, Y, Z)
axis equal

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by