| geom_label_contour {metR} | R Documentation | 
Label contours
Description
Draws labels on contours built with ggplot2::stat_contour.
Usage
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
)
Arguments
| 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, either as a  | 
| position | Position adjustment, either as a string, or the result of
a call to a position adjustment function. Cannot be jointly 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  | 
Details
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().
Aesthetics
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
See Also
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()
Examples
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))