Search notes:

Coloring graphics in R: gray shades

With gray it's possible to create a palette of gray shades and then to apply the colors to the graphic.
In the following example, the »darkness« of a color corresponds to the rank of height of the bar:
x11()

heights <- c(  12, 15, 8, 9, 14, 13, 9 )

relative_heights = rank(heights) / length(heights)

gray_shades = grey(1 - relative_heights)

barplot(heights, col=gray_shades)


# wait for mouse click or enter pressed
z <- locator(1)
Github repository about-r, path: /graphics/coloring/gray-shades.R

See also

Coloring graphics with R
barplot, rank, length

Index