To set background color in a plot in Matlab, you can use the set
function and set the 'Color'
property of the 'figure'
or 'axes'
object. Here is an example:
main.m216 chars9 lines
In this example, I first create a plot of the sine function. Then I set the background color of the figure (gcf
) to light grey ([0.8 0.8 0.8]
) using the set
function. Finally, I set the background color of the axes (gca
) to lightest grey ([0.95 0.95 0.95]
).
Note that you can set the 'Color'
property to any valid RGB triplet, which is a three-element vector [R G B]
with values between 0 and 1 that defines the intensities of the red, green, and blue components of the color.
gistlibby LogSnag