Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Change Color of Grid

Subject: Change Color of Grid

From: Hubert Kargl

Date: 18 Nov, 2003 03:02:27

Message: 1 of 2

Does anybody know how to change the grid-color in a plot without
changing the color of the axes labels.
For example I wand to have grey grid lines but black text at the axes
labels.

I tried it with commands like
"set(gca,'XColor'..." but in this case the color of grid lines AND
the axes labels are changed ?!

Subject: Change Color of Grid

From: Leandro

Date: 24 Nov, 2003 13:51:11

Message: 2 of 2

Hubert Kargl wrote:
>
>
> Does anybody know how to change the grid-color in a plot without
> changing the color of the axes labels.
> For example I wand to have grey grid lines but black text at the
> axes
> labels.
>
> I tried it with commands like
> "set(gca,'XColor'..." but in this case the color of grid lines AND
> the axes labels are changed ?!

You can leave the grid of and use hline and vline to plot the grid:

h=hline(get(gca,'Ytick'),':k');
set(h,'Color',[.8 .8 .8]);

h=vline(get(gca,'Xtick'),':k');
set(h,'Color',[.8 .8 .8]);

You can get hline and vline from :

 <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1039&objectType=file>

Regards,

LB

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us