polyShade | R Documentation |
Color or shade the area under a curve.
polyShade(
x,
y,
from = -Inf,
to = Inf,
n = 1000,
miny = min(y, na.rm = TRUE),
horiz = FALSE,
...
)
x, y |
x- and y-values from the curve |
from |
a vector of x-coordinates from which to color |
to |
a vector of x-coordinates to which to color (same length)
as |
n |
tuning parameter for fitting the shading region to the curve; a lower value will result in a worse fit around the curve |
miny |
by default, shading will extend from the curve to |
horiz |
logical; if |
... |
additional parameters passed to |
http://www.fromthebottomoftheheap.net/2013/01/11/shading-regions-under-a-curve/
set.seed(1)
x <- density(c(rnorm(75), rnorm(25, 5)))
plot(x)
polyShade(x$x, x$y, -1, 2, col = 'red', border = NA)
polyShade(x$x, x$y, from = c(-Inf, 6), to = c(-2, Inf),
col = adjustcolor('red', .3), border = NA)
polyShade(x$x, x$y, 0, 4, col = 'blue', density = 20, lty = 4,
miny = par('usr')[1], border = NA)
## horizontal
plot(x$y, x$x, type = 'l')
polyShade(x$x, x$y, horiz = TRUE, col = 'blue')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.