Change axes position in tiled layout
Mostra commenti meno recenti
Hello,
I am trying to minimize my spacing in a tiled layout. As some y axes have labels and some don't, the TileSpacing settings dont quite do the job. Therefore, I want to set each individual axes position.
This is possible with the property inspector by just dragging the axes, so I guess it should also be possible by code. However, when I try to do this, I get the warning: 'Warning: Unable to set 'Position', 'InnerPosition', 'OuterPosition', or 'PositionConstraint' for objects in a TiledChartLayout ' and it does not have any effect.
Here is an example code:
tiledlayout(2,1)
nexttile
plot(rand(5,1))
nexttile
plot(rand(5,1))
set(gca,'Position',[0.5,0.1,0.2,0.2])
I also tried to define the "nexttile" as an object and change its position, but it has the same result.
Does anyone have a solution for this?
Cheers,
Andreas
Risposta accettata
Più risposte (1)
The position property for a tiledlayout refers to the position of the whole layout not each tile, see here - https://in.mathworks.com/help/matlab/ref/matlab.graphics.layout.tiledchartlayout-properties.html#mw_a2d6defe-bbec-469d-9571-f7d2c3d47968
You can use subplot in this case -
pos1 = [0.1 0.3 0.3 0.3];
subplot('Position',pos1)
y = magic(4);
plot(y)
title('First Subplot')
pos2 = [0.5 0.15 0.4 0.7];
subplot('Position',pos2)
bar(y)
title('Second Subplot')
Categorie
Scopri di più su Graphics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

