Changes in camera viewpoint parameters cannot be constrained within the axial coordinate area?

조회 수: 5 (최근 30일)
For example, I want to display my drawing in the lower left part of the axis area of the figure window, defining position=[0,0,0.5,0.5], but when I change the camera parameter CameraViewAngle, the drawing fills the entire figure area, any suggestions?
% define my axes visual region, bottom left
ax = axes(Position=[0.0,0.0,0.5,0.5]);
% my plot
[X, Y, Z] = sphere(30);
surf(ax, X, Y, Z,FaceColor="none",EdgeColor="black");
% my camera setting
ax.DataAspectRatio = [1,1,1];
ax.CameraPosition = [0,0,0];
ax.CameraTarget = [1,0,0];
ax.CameraUpVector = [0,0,1];
set camera parameter CameraViewAngle
ax.CameraViewAngle = 100
ax =
Axes with properties: XLim: [-1 1] YLim: [-1 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0 0 0.5000 0.5000] Units: 'normalized' Use GET to show all properties
% ax.Projection = 'perspective';%'orthographic';%'perspective';
then chage view angle to 20,the area displayed in the figure window has also changed
ax.CameraViewAngle = 20
show result:
The position properties of the axes remains unchanged,while the drawing fills the entire figure area? What can I do to get my drawing within the [0,0,0.5,0.5] lower left area?
References:

채택된 답변

cui,xingxing
cui,xingxing 2024년 9월 12일
편집: cui,xingxing 2024년 9월 13일
After careful investigation and thought, axes itself is camera controlled, and the default parent object is figure, if you want to limit the area, you can do so by specifying Panel, Tab object.
But specifying tiledlayout, uigridlayout object can't work! If anyone knows anything, please let me know.
p = uipanel(Position=[0.0,0.0,0.5,0.5]);
% define my axes visual region, bottom left
ax = axes(p);
% my plot
[X, Y, Z] = sphere(30);
surf(ax, X, Y, Z,FaceColor="none",EdgeColor="black");
% my camera setting
ax.DataAspectRatio = [1,1,1];
ax.CameraPosition = [0,0,0];
ax.CameraTarget = [1,0,0];
ax.CameraUpVector = [0,0,1];
ax.CameraViewAngle = 20
ax =
Axes with properties: XLim: [-1 1] YLim: [-1 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Use GET to show all properties
  댓글 수: 2
Jatin
Jatin 2024년 9월 12일
편집: Jatin 2024년 9월 12일
I think even using tiled layout does not seem to work here.
% Create a tiled layout with 2 rows and 2 columns
t = tiledlayout(2, 2);
% Access the lower-left tile by specifying the tile index
ax = nexttile(3); % The lower-left tile in a 2x2 grid
% Create the plot within the selected tile
[X, Y, Z] = sphere(30);
surf(ax, X, Y, Z, 'FaceColor', 'none', 'EdgeColor', 'black');
% my camera setting
ax.DataAspectRatio = [1,1,1];
ax.CameraPosition = [0,0,0];
ax.CameraTarget = [1,0,0];
ax.CameraUpVector = [0,0,1];
ax.CameraViewAngle = 20;
cui,xingxing
cui,xingxing 2024년 9월 13일
편집: cui,xingxing 2024년 9월 13일
% Create a grid layout with 2 rows and 2 columns
t = uigridlayout([2, 2]);
% Access the lower-left tile by specifying the row and colum
ax = uiaxes(t);
ax.Layout.Row=2;
ax.Layout.Column = 1;
% Create the plot within the selected tile
[X, Y, Z] = sphere(30);
surf(ax, X, Y, Z, 'FaceColor', 'none', 'EdgeColor', 'black');
% my camera setting
ax.DataAspectRatio = [1,1,1];
ax.CameraPosition = [0,0,0];
ax.CameraTarget = [1,0,0];
ax.CameraUpVector = [0,0,1];
ax.CameraViewAngle = 20;
Thanks for the experiment.@Jatin,I switched to gridlayout and it doesn't work too, only panel, tab can limit the area.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Camera Views에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by