Description Usage Arguments See Also Examples
ggplot2 version of matplot base graphic
1 |
x |
vector for the x-axis variable |
y |
a matrix or a data.frame for the y-axis variables |
type |
character string indicating the type of plot for each column of y. Possible values are |
pch |
character string or vector of 1-characters or integers for plotting characters |
lty |
vector of line types |
col |
vector of colors |
legend |
boolean specifying if a legend should be added or not |
... |
additional arguments |
plot |
boolean specifying if the graph should be added to an existing plot. If |
matplot
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 | x <- 0:50/50
sines <- outer(x, 1:4, function(x, y) sin(y*pi*x))
ggmatplot(x, sines)
ggmatplot(x, sines, type = "l")
ggmatplot(x, sines, type = "b", lty = 1)
# parallel coordinate plot
x = t(apply(iris[,1:4], 2, function(x) (x-min(x))/(max(x)-min(x))))
ggmatplot(x, type = "l", lty = 1, col = 1) +
scale_x_continuous(labels = rownames(x))
ggmatplot(x, type = "l", lty = 1,
col = as.numeric(iris$Species)+1) +
scale_x_continuous(labels = rownames(x))
# add to an existing ggplot graph
mod1 = lm(Ozone ~ Temp, data = airquality)
mod2 = lm(Ozone ~ poly(Temp,2), data = airquality)
mod3 = lm(Ozone ~ poly(Temp,3), data = airquality)
df = data.frame(Temp = seq(56, 97, by = 0.1))
df = cbind(df, pred1 = predict(mod1, df),
pred2 = predict(mod2, df),
pred3 = predict(mod3, df))
ggplot(data = airquality, aes(x = Temp, y = Ozone)) +
geom_point()
ggmatplot(df$Temp, df[,-1], type = "l", lty = 1, col = 2:4,
add = TRUE, legend = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.