Colour bars/Display: Difference between revisions

Line 488:
 
=={{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]]
<lang R>
pal <- c("black", "red", "green", "blue", "magenta", "cyan", "yellow", "white")
par(mar = rep(0, 4)) # set margins to zero so image will fill display
image(matrix(1:8), col = pal, axes = FALSE)
</lang>
Anonymous user