Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change color and thickness of grid in plot

2,026 views
Skip to first unread message

Niles

unread,
Sep 24, 2011, 5:44:14 AM9/24/11
to
Hi

Please see the following example:


a = [1 2 3];
b = [1 2 3];
figure(1)
hold on
plot(a, b, 'o', 'MarkerFaceColor', 'k')
legend('Perturbed');
grid on
set(gca,'GridLineStyle','-')
hold off

I think the grid is too dominant in the plot, so I am interested in

1) Reducing the thickness
2) Changing the grid color (not the axes)

I tried searching, but no hits on these matters. Can You give me a
hint?

Cheers,
Niels.

dpb

unread,
Sep 24, 2011, 12:47:17 PM9/24/11
to
On 9/24/2011 4:44 AM, Niles wrote:
...

> I think the grid is too dominant in the plot, so I am interested in
>
> 1) Reducing the thickness
> 2) Changing the grid color (not the axes)
>
> I tried searching, but no hits on these matters. Can You give me a
> hint?
...

set(gca)

will echo all properties and the list of options available.

My release is pretty old and only gridlinestyle appears adjustable;
there may be more choices in later releases.

I'd suggest the ':' choice or '--' for starters instead of the solid
line selection '-'

--

matt dash

unread,
Sep 24, 2011, 2:38:08 PM9/24/11
to
dpb <no...@non.net> wrote in message <j5l1ji$f26$1...@speranza.aioe.org>...
As far as i know there is no way to change the grid line thickness, and i'd be very surprised if it is possible. There is also no way to change the color without also changing the color of the axes and tick mark labels. So what you need to do (presuming you want black axes/labels) is make an exact copy of the axes underneath your existing axes, set its color to something lighter (set(a,'color',[.7 .7 .7])) and display its gridlines. Turn off the gridlines on the top axes. I find that light gray solid lines work a lot better than darker dashed lines, which are just distracting.
0 new messages