Spacey
Spacey

Reputation: 3011

Colors of MATLAB tickmarks VS grid

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.

Upvotes: 2

Views: 1353

Answers (1)

jasxun
jasxun

Reputation: 581

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

Upvotes: 7

Related Questions