View source: R/geom_textcontour.R
geom_textcontour | R Documentation |
Contour lines are available already in ggplot2, but the
native geom_contour
does not allow the lines to
be labelled with the level of each contour. geom_textcontour
adds this
ability.
geom_textcontour( mapping = NULL, data = NULL, stat = "textcontour", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, lineend = "butt", linejoin = "round", linemitre = 10, bins = NULL, binwidth = NULL, breaks = NULL, ... ) geom_labelcontour( mapping = NULL, data = NULL, stat = "textcontour", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ..., lineend = "butt", linejoin = "round", linemitre = 10, bins = NULL, binwidth = NULL, breaks = NULL, label.padding = unit(0.25, "lines"), label.r = unit(0.15, "lines"), arrow = NULL ) stat_textcontour( mapping = NULL, data = NULL, geom = "textcontour", position = "identity", ..., bins = NULL, binwidth = NULL, breaks = NULL, na.rm = FALSE, 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, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
bins |
Number of contour bins. Overridden by |
binwidth |
The width of the contour bins. Overridden by |
breaks |
Numeric vector to set the contour breaks. Overrides |
... |
Other arguments passed on to
|
label.padding |
Amount of padding around label. Defaults to 0.25 lines. |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
arrow |
Arrow specification, as created by |
geom |
The geometric object to use display the data |
A Layer
ggproto object that can be added to a plot.
geom_textcontour()
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
angle
colour
family
fontface
group
hjust
linecolour
lineheight
linetype
linewidth
size
spacing
textcolour
vjust
In addition to aforementioned aesthetics, geom_labelcontour()
also understands:
boxcolour
boxlinetype
boxlinewidth
fill
The spacing
aesthetic allows fine control of spacing
of text, which is called 'tracking' in typography.
The default is 0 and units are measured in 1/1000 em.
Numbers greater than zero increase the spacing,
whereas negative numbers decrease the spacing.
Learn more about setting these aesthetics
in vignette("ggplot2-specs")
.
The variable 'level' is a numeric or a factor depending on whether lines or bands are calculated.
Height of contour. This is a numeric vector that represents bin boundaries.
Other geom layers that place text on paths.
df <- expand.grid(x = seq(nrow(volcano)), y = seq(ncol(volcano))) df$z <- as.vector(volcano) ggplot(df, aes(x, y, z = z)) + geom_contour_filled(bins = 6, alpha = 0.6) + geom_textcontour(bins = 6, size = 2.5, padding = unit(0.05, "in")) + scale_fill_manual(values = terrain.colors(11)) + theme_classic() + theme(legend.position = "none")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.