Legend position change after printing
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149656/image.jpeg)
and the figure below is the figure saved in the file
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149658/image.jpeg)
As you can see, the position of the legend changes. Is this a bug of Matlab? I'm using R2015a
0 Kommentare
Antworten (6)
Brian Pierre
am 14 Jun. 2016
I have the same issue in 2014b. A big problem for a large automated report with thousands of figures.
0 Kommentare
Abhinav Gupta
am 21 Mai 2022
Bearbeitet: Abhinav Gupta
am 21 Mai 2022
This problem still exists in the R2021b. It would be great if this could be fixed!
0 Kommentare
Eric Delaunay
am 19 Jan. 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.
1 Kommentar
Rohit Kudva
am 22 Okt. 2015
Hi Junyi,
I work for MathWorks and I have forwarded this feedback to the appropriate product team.
Regards,
Rohit
1 Kommentar
Thorsten
am 15 Jun. 2016
Use
set(gcf,'PaperPositionMode','auto');
before printing. It works for me (R1015b).
0 Kommentare
Mark Kerssenfischer
am 2 Dez. 2022
Indeed, I just ran into the same issue in Matlab R2021b.
Please fix it!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!