View source: R/geom_profileglyph.R
geom_profileglyph | R Documentation |
The profileglyph geom is used to plot multivariate data as profile glyphs \insertCitechambers_graphical_1983,dutoit_graphical_1986gglyph in a scatterplot.
geom_profileglyph( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., cols = character(0L), width = 10, size = 1, colour.bar = NULL, colour.line = NULL, colour.grid = NULL, linewidth.line = 1, linewidth.bar = 1, linewidth.grid = 1, fill.bar = NULL, fill.gradient = NULL, flip.axes = FALSE, bar = TRUE, line = TRUE, mirror = TRUE, draw.grid = FALSE, show.legend = NA, repel = FALSE, repel.control = gglyph.repel.control(), 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, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
cols |
Name of columns specifying the variables to be plotted in the glyphs as a character vector. |
width |
The width of the bars. |
size |
The size of glyphs. |
colour.bar |
The colour of bars. |
colour.line |
The colour of profile line(s). |
colour.grid |
The colour of the grid lines. |
linewidth.line |
The line width of the profile line(s) |
linewidth.bar |
The line width of the bars. |
linewidth.grid |
The line width of the grid lines. |
fill.bar |
The fill colour of the bars. |
fill.gradient |
The palette for gradient fill of the segments. See
Details section of |
flip.axes |
logical. If |
bar |
logical. If |
line |
logical. If |
mirror |
logical. If |
draw.grid |
logical. If |
show.legend |
logical. Should this layer be included in the legends?
|
repel |
logical. If |
repel.control |
A list of control settings for the repel algorithm.
Ignored if |
inherit.aes |
If |
A geom
layer.
geom_pieglyph()
understands the following
aesthetics (required aesthetics are in bold):
x
y
alpha
colour
fill
group
See vignette("ggplot2-specs", package = "ggplot2")
for further
details on setting these aesthetics.
The following additional aesthetics are considered if repel = TRUE
:
point.size
segment.linetype
segment.colour
segment.size
segment.alpha
segment.curvature
segment.angle
segment.ncp
segment.shape
segment.square
segment.squareShape
segment.inflect
segment.debug
See ggrepel
examples page
for further details on setting these aesthetics.
profileglyphGrob
Other geoms:
geom_dotglyph()
,
geom_metroglyph()
,
geom_pieglyph()
,
geom_starglyph()
,
geom_tileglyph()
# Scale the data zs <- c("hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb") mtcars[ , zs] <- lapply(mtcars[ , zs], scales::rescale) mtcars$cyl <- as.factor(mtcars$cyl) mtcars$lab <- row.names(mtcars) library(ggplot2) theme_set(theme_bw()) options(ggplot2.discrete.colour = RColorBrewer::brewer.pal(8, "Dark2")) options(ggplot2.discrete.fill = RColorBrewer::brewer.pal(8, "Dark2")) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Mapped fill + line ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, line = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, line = FALSE, mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, line = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, line = FALSE, mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Mapped fill + bar ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, bar = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, bar = FALSE, mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, bar = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, bar = FALSE, mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Mapped colour + bar and line ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Mapped colour + line ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, line = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, line = FALSE, mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, line = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, line = FALSE, mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Mapped colour + bar ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, bar = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, bar = FALSE, mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, bar = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, bar = FALSE, mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Bars with different fill + bar and line ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Bars with different fill + bar ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Bars with gradient fill + bar and line ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.gradient = "Greens", alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.gradient = "Blues", mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.gradient = "RdYlBu", flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.gradient = "viridis", mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Bars with gradient fill + bar ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.gradient = "Greens", alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.gradient = "Blues", mirror = FALSE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.gradient = "RdYlBu", flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, line = FALSE, fill.gradient = "viridis", mirror = FALSE, flip.axes = TRUE, alpha = 0.8) + ylim(c(-0, 550)) # Faceted ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, alpha = 0.8) + ylim(c(-0, 550)) + facet_grid(. ~ cyl) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, alpha = 0.8) + ylim(c(-0, 550)) + facet_grid(. ~ cyl) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), alpha = 0.8) + ylim(c(-0, 550)) + facet_grid(. ~ cyl) # Repel glyphs ggplot(data = mtcars) + geom_point(aes(x = mpg, y = disp, colour = cyl)) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, alpha = 1, repel = TRUE) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_point(aes(x = mpg, y = disp, colour = cyl)) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, line = FALSE, mirror = FALSE, alpha = 1, repel = TRUE) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_point(aes(x = mpg, y = disp, colour = cyl)) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 5, width = 1, bar = FALSE, flip.axes = TRUE, alpha = 1, repel = TRUE) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_point(aes(x = mpg, y = disp, colour = cyl)) + geom_profileglyph(aes(x = mpg, y = disp, colour = cyl), cols = zs, size = 5, width = 1, mirror = FALSE, flip.axes = TRUE, alpha = 1, repel = TRUE) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_point(aes(x = mpg, y = disp)) + geom_profileglyph(aes(x = mpg, y = disp), cols = zs, size = 5, width = 1, fill.bar = RColorBrewer::brewer.pal(8, "Dark2"), alpha = 1, repel = TRUE) + ylim(c(-0, 550)) rm(mtcars) mtcars[ , zs] <- lapply(mtcars[ , zs], scales::rescale) mtcars[ , zs] <- lapply(mtcars[, zs], function(x) cut(x, breaks = 3, labels = c(1, 2, 3))) mtcars[ , zs] <- lapply(mtcars[ , zs], as.factor) mtcars$cyl <- as.factor(mtcars$cyl) mtcars$lab <- row.names(mtcars) # Grid lines (when bar = TRUE) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 3, width = 1, alpha = 0.8, draw.grid = TRUE) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, col = cyl), cols = zs, size = 3, width = 1, alpha = 0.8, draw.grid = TRUE) + ylim(c(-0, 550)) ggplot(data = mtcars) + geom_profileglyph(aes(x = mpg, y = disp, fill = cyl), cols = zs, size = 3, width = 1, fill.gradient = "Blues", alpha = 0.8, draw.grid = TRUE) + ylim(c(-0, 550))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.