gray

Colormap of linear shades of gray, from black to white.

Category: Graphics > Formatting and Annotation

Syntax

map = gray

Returns a gray colormap with the default number of rows.

map = gray(m)

Returns a gray colormap with m rows.

Description

Each row has equal red, green and blue values, spaced evenly from black in the first row to white in the last. It is a good choice for images that should look like a black-and-white photograph and for figures that will be printed without color.

Input arguments

m
Number of colors, a nonnegative integer.

Output arguments

map
m-by-3 matrix whose three columns are equal, running from 0 to 1.

Example

Four gray levels

gray(4)
Output
ans = 4×3

         0         0         0
    0.3333    0.3333    0.3333
    0.6667    0.6667    0.6667
    1.0000    1.0000    1.0000

See also

colormap bone hot imshow rgb2gray