MATLAB: Recessionplot overlays lines on plot

plotrecessionplot

I'm making a plot and adding a recessionplot to it. The plot is saved as an .eps file.
As you can clearly see, the recessionplot is on top of the lines, which are needed on the plot.
This is only the case when the plot is saved. It looks fine in Matlab.
This is my code:
fig=figure
plot(dates, bdat(:,2:6)*100)
datetick('x',"yyyy")
ylabel('Bond Yields (%)')
xlabel('Time')
set(0,"DefaultLegendAutoUpdate","off")
legend('1 Year bond','2 Year bond','3 Year bond','4 Year bond','5 Year bond')
recessionplot
print(fig, "-depsc", "-painters", "timeseriesyields.eps")

Best Answer

Alright, I managed to solve it. Turns out looking at page 2 on google results does yield answers sometime.
This is the code that solved my problem. The plot is now pdf, but it looks good.
fig=figure
plot(dates, bdat(:,2:6)*100)
datetick('x',"yyyy")
ylabel('Bond Yields (%)')
xlabel('Time')
set(0,"DefaultLegendAutoUpdate","off")
legend('1 Year bond','2 Year bond','3 Year bond','4 Year bond','5 Year bond')
recessionplot
fig = gcf;
fig.PaperPositionMode = "auto";
fig_pos = fig.PaperPosition;
fig.PaperSize = [fig_pos(3) fig_pos(4)];
print(fig,"filename","-dpdf")
Related Question