View source: R/geom_text_contour.R
geom_label_contour | R Documentation |
Draws labels on contours built with ggplot2::stat_contour.
geom_label_contour(
mapping = NULL,
data = NULL,
stat = "text_contour",
position = "identity",
...,
min.size = 5,
skip = 1,
label.placer = label_placer_flattest(),
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
label.padding = grid::unit(0.25, "lines"),
label.r = grid::unit(0.15, "lines"),
label.size = 0.25,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_text_contour(
mapping = NULL,
data = NULL,
stat = "text_contour",
position = "identity",
...,
min.size = 5,
skip = 1,
rotate = TRUE,
label.placer = label_placer_flattest(),
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
stroke = 0,
check_overlap = FALSE,
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.
When using a
|
position |
A position adjustment to use on the data for this layer.
Cannot be jointy specified with
|
... |
Other arguments passed on to
|
min.size |
minimum number of points for a contour to be labelled. |
skip |
number of contours to skip |
label.placer |
a label placer function. See |
parse |
If |
nudge_x , nudge_y |
Horizontal and vertical adjustment to nudge labels by.
Useful for offsetting text from points, particularly on discrete scales.
Cannot be jointly specified with |
label.padding |
Amount of padding around label. Defaults to 0.25 lines. |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
label.size |
Size of label border, in mm. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
rotate |
logical indicating whether to rotate text following the contour. |
stroke |
numerical indicating width of stroke relative to the size of the text. Ignored if less than zero. |
check_overlap |
If |
Is best used with a previous call to ggplot2::stat_contour with the same
parameters (e.g. the same binwidth
, breaks
, or bins
).
Note that while geom_text_contour()
can angle itself to follow the contour,
this is not the case with geom_label_contour()
.
geom_text_contour
understands the following aesthetics (required aesthetics are in bold):
x
y
label
alpha
angle
colour
stroke.color
family
fontface
group
hjust
lineheight
size
vjust
Other ggplot2 helpers:
MakeBreaks()
,
WrapCircular()
,
geom_arrow()
,
geom_contour2()
,
geom_contour_fill()
,
geom_relief()
,
geom_streamline()
,
guide_colourstrip()
,
map_labels
,
reverselog_trans()
,
scale_divergent
,
scale_longitude
,
stat_na()
,
stat_subset()
library(ggplot2)
v <- reshape2::melt(volcano)
g <- ggplot(v, aes(Var1, Var2)) +
geom_contour(aes(z = value))
g + geom_text_contour(aes(z = value))
g + geom_text_contour(aes(z = value), stroke = 0.2)
g + geom_text_contour(aes(z = value), stroke = 0.2, stroke.colour = "red")
g + geom_text_contour(aes(z = value, stroke.colour = after_stat(level)), stroke = 0.2) +
scale_colour_gradient(aesthetics = "stroke.colour", guide = "none")
g + geom_text_contour(aes(z = value), rotate = FALSE)
g + geom_text_contour(aes(z = value),
label.placer = label_placer_random())
g + geom_text_contour(aes(z = value),
label.placer = label_placer_n(3))
g + geom_text_contour(aes(z = value),
label.placer = label_placer_flattest())
g + geom_text_contour(aes(z = value),
label.placer = label_placer_flattest(ref_angle = 90))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.