To set the color of grids in MATLAB, you can use the GridColor
property of either the Axes
object or the Line
object. Here is an example of how to set the grid color of an Axes
object:
main.m162 chars11 lines
In this example, gca
is used to get the current Axes
object, which is stored in a variable named ax
. Then, the GridColor
property of ax
is set to [0 0 1]
, which is the RGB value for blue.
Alternatively, you can set the grid color of a specific Line
object in a plot like this:
main.m341 chars17 lines
In this example, findobj
is used to get a list of all the Line
objects in the current figure. Then, the first Line
object is stored in a variable named line1
. Finally, line1
's color
, LineStyle
, LineWidth
, Marker
, and MarkerFaceColor
are all set to different values.
gistlibby LogSnag