mncolors | R Documentation |
This function creates a vector of n
equally spaced colors along a MN color palette.
mncolors(n, palette = "primary", alpha = 1, begin = 0, end = 1, direction = 1)
primary(n, alpha = 1, begin = 0, end = 1, direction = 1)
n |
The number of colors ( |
palette |
A character string indicating the MN palette. The options available are: "primary", "accent", "extended", "blue", "green", "gray", "safety", "primary_accent", "primary_extended", "primary_accent_extended", "corn", "treefrog", and "crayfish". |
alpha |
The alpha transparency, a number in [0,1], see argument alpha in
|
begin |
The (corrected) hue in [0,1] at which the colormap begins. |
end |
The (corrected) hue in [0,1] at which the colormap ends. |
direction |
Sets the order of colors in the scale. If 1, the default, colors are ordered from darkest to lightest. If -1, the order of colors is reversed. |
Here are the color scales:
Semi-transparent colors (0 < alpha < 1
) are supported only on some
devices: see rgb
.
mncolors
returns a character vector, cv
, of color hex
codes. This can be used either to create a user-defined color palette for
subsequent graphics by palette(cv)
, a col =
specification in
graphics functions or in par
.
Dorian Kvale: @state.mn.us, @MN Style Guide
library(ggplot2)
library(hexbin)
dat <- data.frame(x = rnorm(10000), y = rnorm(10000))
ggplot(dat, aes(x = x, y = y)) +
geom_hex() + coord_fixed() +
scale_fill_gradientn(colors = mncolors(256, palette = "primary_extended"))
# using code from RColorBrewer to demo the palette
n = 200
image(
1:n, 1, as.matrix(1:n),
col = mncolors(n, palette = "blue"),
xlab = "mncolors n", ylab = "", xaxt = "n", yaxt = "n", bty = "n"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.