layer_barchart.Rd
layer_barchart
layer_barchart(
mapping = NULL,
data = NULL,
brks,
cols,
x = 0,
y = 0,
width = unit(0.5, "npc"),
height = unit(0.5, "npc"),
just = c(0, 0),
fontsize = 12,
theme = NULL,
...
)
geom_barchart(
mapping = NULL,
data = NULL,
brks,
cols,
x = 0,
y = 0,
width = unit(0.5, "npc"),
height = unit(0.5, "npc"),
just = c(0, 0),
fontsize = 12,
theme = NULL,
...
)
Set of aesthetic mappings created by aes()
. If specified and
inherit.aes = TRUE
(the default), it is combined with the default mapping
at the top level of the plot. You must supply mapping
if there is no plot
mapping.
The data to be displayed in this layer. There are three options:
If NULL
, the default, the data is inherited from the plot
data as specified in the call to ggplot()
.
A data.frame
, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
fortify()
for which variables will be created.
A function
will be called with a single argument,
the plot data. The return value must be a data.frame
, and
will be used as the layer data. A function
can be created
from a formula
(e.g. ~ head(.x, 10)
).
A numeric vector or unit object specifying x-location.
A numeric vector or unit object specifying y-location.
Bar width. By default, set to 90% of the resolution()
of the
data.
A numeric vector or unit object specifying height.
Adjustment for column placement. Set to 0.5
by default, meaning
that columns will be centered about axis breaks. Set to 0
or 1
to place
columns to the left/right of axis breaks. Note that this argument may have
unintended behaviour when used with alternative positions, e.g.
position_dodge()
.
Other arguments passed on to layer()
's params
argument. These
arguments broadly fall into one of 4 categories below. Notably, further
arguments to the position
argument, or aesthetics that are required
can not be passed through ...
. Unknown arguments that are not part
of the 4 categories below are ignored.
Static aesthetics that are not mapped to a scale, but are at a fixed
value and apply to the layer as a whole. For example, colour = "red"
or linewidth = 3
. The geom's documentation has an Aesthetics
section that lists the available options. The 'required' aesthetics
cannot be passed on to the params
. Please note that while passing
unmapped aesthetics as vectors is technically possible, the order and
required length is not guaranteed to be parallel to the input data.
When constructing a layer using
a stat_*()
function, the ...
argument can be used to pass on
parameters to the geom
part of the layer. An example of this is
stat_density(geom = "area", outline.type = "both")
. The geom's
documentation lists which parameters it can accept.
Inversely, when constructing a layer using a
geom_*()
function, the ...
argument can be used to pass on parameters
to the stat
part of the layer. An example of this is
geom_area(stat = "density", adjust = 0.5)
. The stat's documentation
lists which parameters it can accept.
The key_glyph
argument of layer()
may also be passed on through
...
. This can be one of the functions described as
key glyphs, to change the display of the layer in the legend.
library(gg.layers)
library(ggplot2)
library(rcolors)
data("d_trendPerc")
d_mask <- mutate(d_trendPerc, mask = perc <= 0.99) # %>% as.data.frame()
brks = seq(0.9, 1, 0.025)
nbrk = length(brks) - 1
cols <- get_color(rcolors$amwg256, nbrk)
# the part of not significant
ggplot(data = d_mask, aes(x, y)) +
geom_raster(aes(fill = perc)) +
layer_barchart(aes(z = perc),
width = unit(0.3, "npc"),
height = unit(0.3, "npc"),
brks = brks, cols = cols)