How to place a sub-axis at a fixed distance from figure border?
Show older comments
Hello everyone,
I am facing a very simple but annoying problem.
I have a zoomed-in plot of experimental data and, in a corner, I have placed a sub-axis with the overview of the entire dataset. Generally, the placement of the axis is given in realive units to the figure
figure("Position", ...);
% Main zoomed-in plot in figure
plot(...
"LineWidth", ...
"Color", ...);
% Adding a second axis in the corner with the overview plot
axes('Position', [.15 .48 .35 .4]) % Placement in relative units of the figure
The main problem is that scaling and resizing the figure changes the aspect ratio and placement of the sub-axis, which is in general not pleasant, especially if, in the plot, also a legend is present, which instead retains the original aspect ratio and, most importantly, is always placed at a fixed distance from the border of the figure.
Is there a easy and robust way to also have the sub-axis at a fixed distance form the figure border (e.g. 20 px from the top and 20 px from the side), regardless of the main figure size?
Thank you all in advance for any help. I will include a capture of the problem.

Accepted Answer
More Answers (0)
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!