Legend position change after printing

조회 수: 10 (최근 30일)
Junyi
Junyi 2015년 10월 2일
댓글: Augustin Arrabie-Aubiès 2023년 8월 9일
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

답변 (6개)

Brian Pierre
Brian Pierre 2016년 6월 14일
I have the same issue in 2014b. A big problem for a large automated report with thousands of figures.

Abhinav Gupta
Abhinav Gupta 2022년 5월 21일
편집: Abhinav Gupta 2022년 5월 21일
This problem still exists in the R2021b. It would be great if this could be fixed!

Eric Delaunay
Eric Delaunay 2023년 1월 19일
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.
  댓글 수: 1
Augustin Arrabie-Aubiès
Augustin Arrabie-Aubiès 2023년 8월 9일
It did the trick for me in 2019b, thanks !

댓글을 달려면 로그인하십시오.


Rohit Kudva
Rohit Kudva 2015년 10월 22일
Hi Junyi,
I work for MathWorks and I have forwarded this feedback to the appropriate product team.
Regards,
Rohit
  댓글 수: 1
Tizian Felix
Tizian Felix 2017년 10월 19일
What was the answer of the appropriate product team?

댓글을 달려면 로그인하십시오.


Thorsten
Thorsten 2016년 6월 15일
Use
set(gcf,'PaperPositionMode','auto');
before printing. It works for me (R1015b).

Mark Kerssenfischer
Mark Kerssenfischer 2022년 12월 2일
Indeed, I just ran into the same issue in Matlab R2021b.
Please fix it!

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by