Chart objects are not displayed in tiled layout

6 Ansichten (letzte 30 Tage)
Hiroko Muneoka
Hiroko Muneoka am 6 Apr. 2022
Beantwortet: Vedant Shah am 28 Apr. 2025
I made (1,3) tiledlayout and tried to plot some chart and primitive objects to each tile by following code.
figure
tiledlayout(1,3)
%plot a rectangle and a parameterized function line to the first tile.
nexttile
ti=rectangle('Position',[0,0,b,l]);
hold on
path=fplot(@(t) pathX(t),@(t) pathY(t),[t0,0]);
%plot a rectangle and a quiver to the second tile.
nexttile
ti=rectangle('Position',[0,0,b,l]);
hold on
ver=quiver(x,y,vx,vy);
%plot a parameterized function line and a polygon to the third tile.
nexttile
path=fplot(@(t) pathX(t),@(t) pathY(t),[t0,0]);
hold on
rect=rotate(rect0,omega,[Xtc,Ytc]);
plot(rect);
However, I can't see the Objects in the first and second tiles, although the Property Inspector shows each Axes contains the objects I tried to plot.

Antworten (1)

Vedant Shah
Vedant Shah am 28 Apr. 2025
The reason the objects are not visible in the first and second tiles, despite their presence in the Property Inspector, is due to the absence of explicit axis settings in the provided code. Without setting the axis limits, MATLAB may use default values that do not incorporate the plotted objects, resulting in their invisibility.
To ensure all objects are displayed as intended, it is recommended to explicitly set the axis properties at the end of each tile’s plotting commands. This can be achieved by adding the following lines:
axis equal
axis([xmin xmax ymin ymax])
Here, “xmin” and “xmax” should be replaced with the minimum and maximum values of the x-data, while “ymin” and “ymax” correspond to the minimum and maximum values of the y-data. Adjusting these values according to the plotted data will ensure that all objects are visible within the axes.
I tried adding the above lines of code to the existing code and executing it for a sample data, the results I obtained are as below where all the tiles contain the proper figure as intended:
For more information, please refer to the following documentation:

Kategorien

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by