2

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.

Community
  • 1
  • 1
Spacey
  • 2,941
  • 10
  • 47
  • 63
  • Perhaps an approach similar to this could be used: http://www.mathworks.com/support/solutions/en/data/1-1PAYMC/?solution=1-1PAYMC ? – Smash Dec 11 '12 at 22:24

1 Answers1

7

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

jasxun
  • 571
  • 1
  • 5
  • 11