Clear Filters
Clear Filters

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

39 views (last 30 days)
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:

Accepted Answer

cui,xingxing
cui,xingxing on 12 Sep 2024 at 8:50
Edited: cui,xingxing on 13 Sep 2024 at 2:05
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 Comments
Jatin
Jatin on 12 Sep 2024 at 9:36
Edited: Jatin on 12 Sep 2024 at 9:36
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 on 13 Sep 2024 at 2:01
Edited: cui,xingxing on 13 Sep 2024 at 2:06
% 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.

Sign in to comment.

More Answers (0)

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!