Colour bars/Display: Difference between revisions

Content added Content deleted
Line 488: Line 488:


=={{header|R}}==
=={{header|R}}==
Create the color palette, set margins to zero so the image will fill the display, and use image to create the graphic:
[[File:ColorBarR.png|thumb|right]]
[[File:ColorBarR.png|thumb|right]]
<lang R>
<lang R>
pal <- c("black", "red", "green", "blue", "magenta", "cyan", "yellow", "white")
pal <- c("black", "red", "green", "blue", "magenta", "cyan", "yellow", "white")
par(mar = rep(0, 4)) # set margins to zero so image will fill display
par(mar = rep(0, 4))
image(matrix(1:8), col = pal, axes = FALSE)
image(matrix(1:8), col = pal, axes = FALSE)
</lang>
</lang>