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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758210182, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/graphics/coloring/gray-shades(59): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78