How can I get .EPS output using yyaxis and for function?

2 views (last 30 days)
Hi, I am encountering an issue regarding taking extracting out the figure after using yyaxis. Although, I am able to extract the figure in .pdf format, this puts the whole page when putting in latex. I can use trim function in latex, but that would not be economical. I tried different ways of extracting output in the form of eps, but none works.
cd 'D:\Matlab\Article\Graphs'
for i=1:20
yyaxis right
plot(dates,prices(:,i));
ylabel('Price','interpreter','latex', 'FontSize',10, 'FontName','Times')
yyaxis left
plot(dates,returns(:,i));
ylabel('Return', 'interpreter','latex', 'FontSize',10, 'FontName','Times')
set(gca, 'FontName', 'Times')
print(sprintf('tsline_%d.pdf', i), '-dpdf', '-bestfit');
end
I used the above given function to extract .pdf.
I am using on one y-axis the price series and the return series on the other and the x-axis constitutes of dates. I have twenty columns for each series and number of observations are 7825. To extract in eps, I used the following function:
cd 'D:\Matlab\Article\Graphs'
for i=1:20
yyaxis right
plot(dates,prices(:,i));
ylabel('Price','FontSize',8)
yyaxis left
plot(dates,returns(:,i));
ylabel('Return', 'FontSize',8)
saveas(gcf,strcat('figure',num2str(i),'.eps'));
i = i+1;
end
However, this gives me just the firs graph output and then stops and returns error of insufficient java memory and error in saveas (line 168). print(h, name, ['-d' dev{i}] ). I changed the saveas to print as well, but the problem persists.
I would really appreciate any sort of help.
Many Thanks. :)
Yahya

Accepted Answer

Walter Roberson
Walter Roberson on 14 May 2017
  3 Comments
Walter Roberson
Walter Roberson on 15 May 2017
Sorry, I do not know of faster methods -- at least not if you want vector output.
Muhammad yahya
Muhammad yahya on 17 May 2017
Thanks Walter! I have used the previous command plotyy, and that is way faster.

Sign in to comment.

More Answers (0)

Categories

Find more on Display Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!