Description Usage Arguments Value Author(s) Examples
The hinge indicates a dramatic color change in a palette that is typically located at the midpoint of the data range. An asymmetrical data range can result in an undesired hinge location, a location that does not necessarily coincide with the break-point in the user's data. This function can be used to specify a hinge location that is appropriate for your data.
1 2 3 4 5 6 7 8 9 10 |
x |
'numeric' object that can be passed to the |
hinge |
'numeric' number. Hinge value (such as, at sea-level) in data units. |
scheme |
'character' vector of length 1 or 2, value is recycled as necessary.
Name of color scheme(s).
The color palette is derived from one or two color schemes.
The scheme(s) must be suitable for continuous data types and allow for color interpolation.
See |
alpha |
'numeric' vector of length 1 or 2, value is recycled as necessary.
Alpha transparency applied separately on either side of the hinge.
Values range from 0 (fully transparent) to 1 (fully opaque).
Specify as |
reverse |
'logical' vector of length 1 or 2, value is recycled as necessary. Whether to reverse the order of colors in the scheme(s). Values applied separately on either side of the hinge. |
buffer |
'numeric' vector of length 1 or 2, value is recycled as necessary. Color buffer around the hinge measured as a fraction of the color range. Values applied separately on either side of the hinge. |
stops |
'numeric' vector of length 2. Color stops defined by interval endpoints (between 0 and 1) and used to select a subset of the color palette(s). |
allow_bias |
'logical' flag. Whether to allow bias in the color spacing. |
A 'function' that takes an 'integer' argument (the required number of colors) and returns a 'character' vector of colors.
J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | Plot <- inlmisc:::plot.inlpal
Pal <- SetHinge(x = c(-3, 7), hinge = 0)
Plot(Pal(n = 19))
x <- datasets::volcano
Pal <- SetHinge(x, hinge = 140, scheme = c("abyss", "dem1"))
filled.contour(x, color.palette = Pal, nlevels = 50,
plot.axes = FALSE)
# Data range (x)
hinge <- 0; n <- 20
op <- par(mfrow = c(5, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(c(-10, 0), hinge)(n))
Plot(SetHinge(c( -7, 3), hinge)(n))
Plot(SetHinge(c( -5, 5), hinge)(n))
Plot(SetHinge(c( -3, 7), hinge)(n))
Plot(SetHinge(c( 0, 10), hinge)(n))
par(op)
# Hinge value (hinge)
x <- c(-5, 5); n <- 255
op <- par(mfrow = c(5, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(x, hinge = -6)(n))
Plot(SetHinge(x, hinge = -2)(n))
Plot(SetHinge(x, hinge = 0)(n))
Plot(SetHinge(x, hinge = 2)(n))
Plot(SetHinge(x, hinge = 6)(n))
par(op)
# Color scheme (scheme)
x <- c(-10, 10); hinge <- -3; n <- 255
op <- par(mfrow = c(3, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(x, hinge, scheme = "roma")(n))
Plot(SetHinge(x, hinge, scheme = "BuRd")(n))
Plot(SetHinge(x, hinge, scheme = c("ocean", "copper"))(n))
par(op)
# Alpha transparency (alpha)
x <- c(-5, 5); hinge <- 0; scheme <- c("drywet", "hawaii"); n <- 255
op <- par(mfrow = c(4, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(x, hinge, scheme, alpha = 1.0)(n))
Plot(SetHinge(x, hinge, scheme, alpha = 0.5)(n))
Plot(SetHinge(x, hinge, scheme, alpha = c(1.0, 0.5))(n))
Plot(SetHinge(x, hinge, scheme, alpha = c(0.5, 1.0))(n))
par(op)
# Reverse colors (reverse)
x <- c(-10, 10); hinge <- -3; n <- 255
op <- par(mfrow = c(6, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(x, hinge, "roma", reverse = FALSE)(n))
Plot(SetHinge(x, hinge, "roma", reverse = TRUE)(n))
Plot(SetHinge(x, hinge, c("davos", "hawaii"),
reverse = FALSE)(n))
Plot(SetHinge(x, hinge, c("davos", "hawaii"),
reverse = TRUE)(n))
Plot(SetHinge(x, hinge, c("davos", "hawaii"),
reverse = c(TRUE, FALSE))(n))
Plot(SetHinge(x, hinge, c("davos", "hawaii"),
reverse = c(FALSE, TRUE))(n))
par(op)
# Buffer around hinge (buffer)
x <- c(-5, 5); hinge <- -2; n <- 20
op <- par(mfrow = c(6, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(x, hinge, buffer = 0.0)(n))
Plot(SetHinge(x, hinge, buffer = 0.2)(n))
Plot(SetHinge(x, hinge, buffer = c(0.4, 0.2))(n))
Plot(SetHinge(x, hinge, c("gray", "plasma"),
buffer = 0.0)(n))
Plot(SetHinge(x, hinge, c("gray", "plasma"),
buffer = 0.2)(n))
Plot(SetHinge(x, hinge, c("gray", "plasma"),
buffer = c(0.2, 0.4))(n))
par(op)
# Color stops (stops)
x <- c(-5, 5); hinge <- 1; n <- 20
op <- par(mfrow = c(6, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(x, hinge, stops = c(0.0, 1.0))(n))
Plot(SetHinge(x, hinge, stops = c(0.2, 0.8))(n))
Plot(SetHinge(x, hinge, stops = c(0.4, 0.6))(n))
Plot(SetHinge(x, hinge, c("gray", "plasma"),
stops = c(0.0, 1.0))(n))
Plot(SetHinge(x, hinge, c("gray", "plasma"),
stops = c(0.2, 0.8))(n))
Plot(SetHinge(x, hinge, c("gray", "plasma"),
stops = c(0.4, 0.6))(n))
par(op)
# Allow bias (allow_bias)
x <- c(-3, 7); n <- 20
op <- par(mfrow = c(4, 1), oma = c(0, 0, 0, 0))
Plot(SetHinge(x, hinge = 0, allow_bias = TRUE)(n))
Plot(SetHinge(x, hinge = 0, allow_bias = FALSE)(n))
Plot(SetHinge(x, hinge = 4, allow_bias = TRUE)(n))
Plot(SetHinge(x, hinge = 4, allow_bias = FALSE)(n))
par(op)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.