Grafika a graphics
csomaggal
Példa
library(wesanderson)
palette <- wes_palette("Darjeeling1", nrow(VADeaths))
x <- barplot(VADeaths, main = "Death Rates in Virginia (1940)",
names.arg = sub(" ", "\n", colnames(VADeaths)),
col = palette)
y <- apply(VADeaths, 2, cumsum) - VADeaths / 2
text(rep(x, each = 5), y, VADeaths)
legend("topright", title = "Age groups",
legend = rownames(VADeaths),
fill = palette)

Példa
pairs(iris[1:4],
pch = 21,
cex = 1.5,
bg = rainbow(3)[iris$Species],
main = "Fisher's Iris Data Set")

Példa
x <- rnorm(100)
plot(ecdf(x), do.points = FALSE, verticals = TRUE)
curve(pnorm, add = TRUE, col = "red")

Példa
x <- seq(-5, 5, length = 100)
y <- x
f <- function(x, y) sin(x * y)
z <- outer(x, y, f)
filled.contour(x, y, z, color.palette = heat.colors)
title(expression(f(x) == sin(x * y)), xlab = "x", ylab = "y")

Példa
f <- function(x, y) besselJ(sqrt(x^2 + y^2), 0)
x <- seq(-10, 10, length = 100)
y <- x
z <- outer(x, y, f)
persp(x, y, z, theta = 45, phi = 30, col = "coral")
title(expression(paste(f(x, y) == J[0], bgroup("(", sqrt(x^2 + y^2), ")"))))

Példa
x <- rgamma(500, 5, 0.5)
h <- hist(x, breaks = 15, freq = FALSE, col = "wheat", main = NULL)
rug(x)
curve(dgamma(x, 5, 0.5), col = "red", lwd = 2, add = TRUE)
title(sub = substitute(paste("Gamma distribution with parameters ", alpha == a, " and ", beta == b),
list(a = 5, b = 0.5)))
expr <- expression(g[list(alpha, beta)](x) == x^{alpha - 1} * frac(beta^alpha * e^{-beta * x}, Gamma(alpha)))
arrows(0.75 * max(x),
0.05, max(x) / 2,
dgamma(max(x) / 2, 5, 0.5),
length = 0.15,
col = "red",
lwd = 2)
text(0.75 * max(x), 0.05, expr, pos = 3)
