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