2
votes

So, I am trying to maintain the (usual) black color of a MATLAB plots' grid, but I want to change the x-axis and y-axis colors to be white. If I do the usual set(gca, 'xcolor', 'w'); (and same for y), it changes the entire grid to be white, which is not what I want.

Is there an easy way to do this?

I have reviewed code here but it has not helped me much.

Thanks.

1
Perhaps an approach similar to this could be used: mathworks.com/support/solutions/en/data/1-1PAYMC/… ?Smash

1 Answers

7
votes

As a quick hack you could redraw the axes with the color you want and the grid turned off:

plot(rand(10,1))
grid on

ax = copyobj(gca, gcf);
set(ax,'color','none','xgrid','off', 'xcolor','w', 'ygrid','off', 'ycolor','w')

Not elegant but works:

enter image description here