How to place a sub-axis at a fixed distance from figure border?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Francesco
el 25 de Oct. de 2024 a las 8:35
Comentada: Francesco
el 25 de Oct. de 2024 a las 10:27
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.
0 comentarios
Respuesta aceptada
Divyajyoti Nayak
el 25 de Oct. de 2024 a las 8:59
To have the sub axis at fixed distances from figure borders instead of relative distances, the 'Units' property of the axes object can be changed from 'normalized' (default) to something like 'pixels'. Here's the documentation to help you out along with some sample code:
figure(1)
ax1 = axes('Position',[0.1 0.1 0.7 0.7]);
ax2 = axes('Units','pixels','Position',[50 300 100 200]);
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!