How to fix the plot box size independetly of the number of digits of the tick labels

2 views (last 30 days)
Hi there,
I have two plots in App Builder that I'd like to have in the same size instead of plotting data in a single plot.
However, one plot has y tick labels with 2 digits, i.e., numbers btw. 0 and 100.
The other plot has numerous digits, e.g., 1550.385.
This automatically changes the size of the plot, i.e., the inner frame. Please see the image below:
Do you guys have a solution?
Thank you for assistance.
Sincerely,
Fabian

Answers (1)

Voss
Voss on 17 Nov 2022
This doesn't appear to happen when using subplot or tiledlayout:
figure
subplot(2,1,1)
plot(0:10,0:10)
subplot(2,1,2)
plot(0:10,(0:10)+10000)
figure
tiledlayout(2,1)
nexttile
plot(0:10,0:10)
nexttile
plot(0:10,(0:10)+10000)
So you may consider using one of those options.
Otherwise, you may write a SizeChangedFcn for the parent of your axes (i.e., the uifigure or uipanel containing the axes), which sets the Position of both axes based on the left-location and the width of the narrower axes (i.e., the one with the longer yticklabels).

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!