geom_siderange {lemon} | R Documentation |
Display range of data in side of plot
Description
Projects data onto horizontal or vertical edge of panels.
Usage
geom_siderange(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
distance = 3,
arrow = NULL,
lineend = "butt",
sides = "bl",
start = NA,
end = NA,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping |
|
data |
The data to be displayed in this layer. |
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
(e.g. |
... |
other arguments passed on to |
distance |
Distance between edge of panel and lines, and distance between lines, in multiples of line widths, see description. |
arrow |
Arrow specification, as created by |
lineend |
Line end style (round, butt, square). |
sides |
Character including top, right, bottom, and/or left, indicating which side to project data onto. |
start , end |
Adds a symbol to either end of the siderange.
|
na.rm |
If |
show.legend |
Logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Details
The geom_siderange
projects the data displayed in the panel onto the
sides, using the same aesthetics. It has the added capability of potting a
symbol at either end
of the line, and lines are offset from the edge and each other.
To display a symbol, specify an integer for either start
or end
.
See the list for pch
in points
for values to use.
The argumetns start
and end
also accepts a list object with
named entries pch
, alpha
, stroke
, and fill
, which
correspond to the usual aesthetics, as well as a special named entry,
sizer
(note the extra 'r').
This last entry is a multiplier for enlarging the symbol relative to the
linewidth, as the aesthetic size
affects both linewidth and symbol size.
The distance between the panel's edge and sideranges are specified by
the argument distance
. If a symbol is specified, the linewidth is
further expanded to cover the width of the symbol (including sizer
).
Aesthetics
The geom understands the following aesthetics (required are in bold):
-
x
-
y
alpha
colour
fill (if a symbol is applied with
start
orend
group
linetype
size
stroke
See Also
Examples
library(ggplot2)
x <- rnorm(25)
df <- data.frame(x=x, y=x+rnorm(25, sd=0.2),
a=sample(c('horse','goat'), 25, replace=TRUE),
stringsAsFactors = FALSE)
df$y <- with(df, ifelse(y > 1 & a=='horse', 1, y))
(p <- ggplot(df, aes(x=x, y=y, colour=a)) + geom_point(shape=1))
p + geom_siderange(start=19)
# Capping the sideranges with different symbols:
p + geom_siderange(start=19, end=22, fill='black', sides='b') + geom_siderange(sides='tl')
# It also works with facets
p <- ggplot(mpg, aes(displ, hwy, colour=fl)) +
geom_point() +
facet_wrap(~class, nrow = 4)
p + geom_siderange()