Legend position change after printing

10 visualizaciones (últimos 30 días)
Junyi
Junyi el 2 de Oct. de 2015
Comentada: Augustin Arrabie-Aubiès el 9 de Ag. de 2023
I draw a bar figure and set the legend using
leg = legend('w/s QOS','w/o QOS','Location','best');
And then I try to save the figure using print
fig2.PaperPositionMode = 'manual';
fig2.PaperUnits = 'points';
fig2.PaperPosition = ([0 0 1920 1080]);
print('./figure/delay_avg','-djpeg');
The following figure is what I have in Matlab window
and the figure below is the figure saved in the file
As you can see, the position of the legend changes. Is this a bug of Matlab? I'm using R2015a

Respuestas (6)

Brian Pierre
Brian Pierre el 14 de Jun. de 2016
I have the same issue in 2014b. A big problem for a large automated report with thousands of figures.

Abhinav Gupta
Abhinav Gupta el 21 de Mayo de 2022
Editada: Abhinav Gupta el 21 de Mayo de 2022
This problem still exists in the R2021b. It would be great if this could be fixed!

Eric Delaunay
Eric Delaunay el 19 de En. de 2023
Found a workaround :
l = findobj(gcf, 'type', 'legend');
set(l, 'Location', 'none');
before printing. It disables auto layout for legend and uses its current 'position' for printing. It works for me in R2017b.

Rohit Kudva
Rohit Kudva el 22 de Oct. de 2015
Hi Junyi,
I work for MathWorks and I have forwarded this feedback to the appropriate product team.
Regards,
Rohit
  1 comentario
Tizian Felix
Tizian Felix el 19 de Oct. de 2017
What was the answer of the appropriate product team?

Iniciar sesión para comentar.


Thorsten
Thorsten el 15 de Jun. de 2016
Use
set(gcf,'PaperPositionMode','auto');
before printing. It works for me (R1015b).

Mark Kerssenfischer
Mark Kerssenfischer el 2 de Dic. de 2022
Indeed, I just ran into the same issue in Matlab R2021b.
Please fix it!

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by