plot grid in background

12 views (last 30 days)
Matthias Pospiech
Matthias Pospiech on 21 Feb 2012
I use the gridxy (<http://www.mathworks.com/matlabcentral/fileexchange/9973-gridxy-v2-2-feb-2008>) function (because the original grid can not be modified properly), which works very well.
But in this example the grid is painted in the foreground in the exported png:
figure(1); clf;
x = [0:0.1:10];
y = sin(xaxis*pi/2).*xaxis;
xtemp = [x(1) ; x(:) ; x(end)] ;
ytemp = [0 ; y(:) ; 0 ] ;
% plot
hplot = fill(xtemp,ytemp, 'b');
set(hplot, 'FaceColor' , [0.5, 0.5, 0.75])
set(hplot, 'EdgeColor' , [0, 0, 0.25])
hgrid = gridxy(get(gca,'XTick'),get(gca,'YTick'),'Color',[0.6 0.6 0.6],'Linestyle','--', 'LineWidth', 0.6);
print(gcf, '-r400', ['test' '.png'], '-dpng');
If I could attach the resulting png you would see the problem directly...

Accepted Answer

Matthias Pospiech
Matthias Pospiech on 4 Mar 2012

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!