scatterplot {BasketballAnalyzeR} | R Documentation |
Draws a scatter plot or a matrix of scatter plots
Description
Draws a scatter plot or a matrix of scatter plots
Usage
scatterplot(
data,
data.var,
z.var = NULL,
palette = NULL,
labels = NULL,
repel_labels = FALSE,
text_label = TRUE,
subset = NULL,
col.subset = "gray50",
zoom = NULL,
title = NULL,
legend = TRUE,
upper = list(continuous = "cor", combo = "box_no_facet", discrete = "facetbar", na =
"na"),
lower = list(continuous = "points", combo = "facethist", discrete = "facetbar", na =
"na"),
diag = list(continuous = "densityDiag", discrete = "barDiag", na = "naDiag")
)
Arguments
data |
an object of class |
data.var |
character or numeric vector, name or column number of variables (in |
z.var |
character or number, name or column number of variable (in |
palette |
color palette (active when plotting a single scatter plot; see Value). |
labels |
character vector, labels for points (active when plotting a single scatter plot, see Value). |
repel_labels |
logical; if |
text_label |
logical; if |
subset |
logical or numeric vector, to select a subset of points to be highlighted (active when plotting a single scatter plot; see Value). |
col.subset |
character, color for the labels and rectangles of highlighted points (active when plotting a single scatter plot; see Value). |
zoom |
numeric vector with 4 elements; |
title |
character, plot title. |
legend |
logical, if |
upper |
list, may contain the variables |
lower |
list, may contain the variables |
diag |
list, may contain the variables |
Details
If length(data.var)=2
, the variable specified in z.var
can be numeric or factor; if length(data.var)>2
, the variable specified in z.var
must be a factor.
Value
A ggplot2
object with a single scatter plot if length(data.var)=2
or a matrix of scatter plots if length(data.var)>2
.
Author(s)
Marco Sandri, Paola Zuccolotto, Marica Manisera (basketball.analyzer.help@gmail.com)
References
P. Zuccolotto and M. Manisera (2020) Basketball Data Science: With Applications in R. CRC Press.
See Also
Examples
# Single scatter plot
Pbox.sel <- subset(Pbox, MIN>= 500)
X <- data.frame(AST=Pbox.sel$AST/Pbox.sel$MIN,TOV=Pbox.sel$TOV/Pbox.sel$MIN)
X$PTSpm <- Pbox.sel$PTS/Pbox.sel$MIN
mypal <- colorRampPalette(c("blue","yellow","red"))
scatterplot(X, data.var=c("AST","TOV"), z.var="PTSpm", labels=1:nrow(X), palette=mypal)
# Matrix of scatter plots
data <- Pbox[1:50, c("PTS","P3M","P2M","OREB","Team")]
scatterplot(data, data.var=1:4, z.var="Team")