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

2 ビュー (過去 30 日間)
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.

採用された回答

Jonathan Thomet
Jonathan Thomet 2019 年 12 月 10 日
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!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by