Plotted data is visible under the 'northeastoutside' legend when using two y-axis and a small xlim. How can I avoid that?

2 visualizaciones (últimos 30 días)
Hi all,
I may have a problem with the print() function with a special case. Here is the end result.
test2.jpg
As you can see, when I x-zoom on my data with two y-axis and a legend outside, while Matlab's figure window will look OK, some of the data will appear in the region under the legend outside the plot area when I print it. Obviously, with the print function, I want the area under the legend to be blank! I have the intuition this is a problem of the print() function, since Matlab's figure window doesn't show this kind of behavior. Maybe this would need a patch from Matlab?
Here is the code I used to create this file:
ffgg = set(figure,'defaultAxesColorOrder',[[0 0 0]; [0 0 0]]);
yyaxis left
plot([0 1 2 3 4 5 6 7 8 9], [1 5 4 6 8 2 9 3 5 3])
hold on
yyaxis right
stem([2 4 6 8],[50 30 60 40])
legend('Location','northeastoutside');
xlim([0 5]) % Up to here, Matlab's figure window looks good!
print('test','-djpeg')
I am using Matlab R2019a - academic use, Update 4 (9.6.0.1150989), on a Windows 10 Education computer, 64 bit. Thank you for any help.

Respuesta aceptada

Jonathan Thomet
Jonathan Thomet el 10 de Dic. de 2019
After contacting Mathlab, I received the solution!
Just add
'-painters'
in the print function. For example,
print(sprintf('%s\\%s',Dpath,fname),'-dpng','-r600','-painters')
and it should work fine!

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by