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
)
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.