geom_treebar {ggtreebar} | R Documentation |
Treemap Bar Charts
Description
ggplot2
geoms analogous to ggplot2::geom_bar()
and ggplot2::geom_col()
that allow for treemaps like with treemapify::geom_treemap()
nested within each bar segment.
Usage
geom_treebar(
mapping = NULL,
data = NULL,
stat = "count",
position = "stack",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
fixed = NULL,
layout = "squarified",
start = "bottomleft",
...
)
geom_treecol(
mapping = NULL,
data = NULL,
stat = "identity",
position = "stack",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
fixed = NULL,
layout = "squarified",
start = "bottomleft",
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Override the default connection between |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
fixed |
Deprecated. Use |
layout |
The layout algorithm, one of either 'squarified' (the default), 'scol', 'srow' or 'fixed'. See Details for full details on the different layout algorithms. |
start |
The corner in which to start placing the tiles. One of 'bottomleft' (the default), 'topleft', 'topright' or 'bottomright'. |
... |
Other arguments passed on to
|
Details
data
is split by all aesthetics except for the subgroup
aesthetics.
A treemap is then drawn using treemapify::treemapify()
from each section
of the data
, inheriting its aesthetics, and using the subgroup
aesthetics
to determine hierarchy.
Value
Aesthetics
geom_treebar()
understands the following aesthetics
(required aesthetics are in bold):
-
x
-
y
-
alpha
-
colour
-
fill
-
linetype
-
linewidth
-
subgroup
-
subgroup2
-
subgroup3
geom_treecol()
understands the following aesthetics
(required aesthetics are in bold):
-
x
-
y
-
alpha
-
colour
-
fill
-
linetype
-
linewidth
-
subgroup
-
subgroup2
-
subgroup3
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
stat_count()
understands the following aesthetics
(required aesthetics are in bold):
-
x
ory
-
group
-
weight
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
Computed variables
These are calculated by the 'stat' part of layers and can be accessed with delayed evaluation.
-
after_stat(count)
number of points in bin. -
after_stat(prop)
groupwise proportion
See Also
geom_treebar_subgroup_border()
, geom_treebar_subgroup_text()
.
Examples
library(ggplot2)
ggplot(diamonds, aes(clarity, fill = cut, subgroup = color)) +
geom_treebar()
ggplot(diamonds, aes(y = cut, fill = color, subgroup = clarity)) +
geom_treebar(position = "dodge")