Friday, June 20, 2008

How to change the color of the grid without changing the color of the ticks

Have you ever tried to change the color of the grid in a plot? right, the color of the axis changes as well. it is not possible to set the color of the grid separately. There is a good workaround here.
ezplot('x')
grid on
set(gca,'Xcolor',[0.85 0.85 0.85])
c_axes = copyobj(gca,gcf);
set(c_axes, 'color', 'none', 'xcolor', 'k', 'xgrid', 'off', 'ycolor','k', 'ygrid','off');


this will generate gray grids, like in the picture above.


1 comment:

abhirami said...

sytax: gridaxeshandle=cgrid(colorarg, stylearg, colorargy)
gridaxishandle=cgrid('g-');