# parallel coordinate
p <- ggplot(NBAstats2021,
mapping = aes(FGA = FGA,
`3PA` = `3PA`,
FTA = FTA,
OFGA = OFGA,
O3PA = O3PA,
OFTA = OFTA,
colour = CONF))
# Teams in West are more likely to make 3-point field goals.
# Besides, they have a better performance in restricting opponents
# to make 3-point field goals.
p +
geom_serialaxes(scaling = "variable",
alpha = 0.4,
linewidth = 3) +
scale_x_continuous(breaks = 1:6,
labels = c("FGA", "3PA", "FTA",
"OFGA", "O3PA", "OFTA")) +
scale_y_continuous(labels = NULL)
# andrews plot
p + geom_serialaxes(stat = "dotProduct",
scaling = "variable",
transform = andrews) # default
# Legendre polynomials
p + geom_serialaxes(stat = "dotProduct",
scaling = "variable",
transform = legendre)
# \donttest{
############# Determine axes sequence
# 1. set the duplicated axes by mapping aesthetics
ggplot(iris, mapping = aes(Sepal.Length = Sepal.Length,
Sepal.Width = Sepal.Width,
Sepal.Length = Sepal.Length,
Sepal.Width = Sepal.Width,
colour = Species)) +
# only two axes, duplicated axes are removed
geom_serialaxes()
# 2. set the duplicated axes by axes.sequence
ggplot(iris, mapping = aes(colour = Species)) +
geom_serialaxes(
axes.sequence = c("Sepal.Length", "Sepal.Width",
"Sepal.Length", "Sepal.Width"))
# }
Run the code above in your browser using DataLab