View source: R/geom-serialaxes.R
geom_serialaxes | R Documentation |
Draw a serial axes layer, parallel axes under Cartesian system and radial axes under Polar system.
It only takes the "widens" data. Each non-aesthetics component defined in the mapping aes()
will
be treated as an axis.
geom_serialaxes( mapping = NULL, data = NULL, stat = "serialaxes", position = "identity", ..., axes.sequence = character(0L), merge = TRUE, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) stat_serialaxes( mapping = NULL, data = NULL, geom = "serialaxes", position = "identity", ..., axes.sequence = character(0L), merge = TRUE, axes.position = NULL, scaling = c("data", "variable", "observation", "none"), na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE ) stat_dotProduct( mapping = NULL, data = NULL, geom = "path", position = "identity", ..., axes.sequence = character(0L), merge = TRUE, scaling = c("data", "variable", "observation", "none"), transform = andrews, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
axes.sequence |
A vector to define the axes sequence. In serial axes coordinate, the sequence can be either
determined in |
merge |
Should |
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom |
The geometric object to use to display the data, either as a
|
axes.position |
A numerical vector to determine the axes sequence position;
the length should be the same with the length of |
scaling |
one of |
transform |
A transformation function, can be either |
The difference between the "lengthens" data and "widens" data can be found in Tidy Data. How to transform one to the other is explained in tidyr
coord_serialaxes
, geom_serialaxes_density
,
geom_serialaxes_quantile
, geom_serialaxes_hist
Andrews plot andrews
, Legendre polynomials legendre
# 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) ############# 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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.