File: position_nudge.Rd

package info (click to toggle)
r-cran-ggplot2 3.5.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 9,944 kB
  • sloc: sh: 15; makefile: 5
file content (45 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/position-nudge.R
\name{position_nudge}
\alias{position_nudge}
\title{Nudge points a fixed distance}
\usage{
position_nudge(x = 0, y = 0)
}
\arguments{
\item{x, y}{Amount of vertical and horizontal distance to move.}
}
\description{
\code{position_nudge()} is generally useful for adjusting the position of
items on discrete scales by a small amount. Nudging is built in to
\code{\link[=geom_text]{geom_text()}} because it's so useful for moving labels a small
distance from what they're labelling.
}
\examples{
df <- data.frame(
  x = c(1,3,2,5),
  y = c("a","c","d","c")
)

ggplot(df, aes(x, y)) +
  geom_point() +
  geom_text(aes(label = y))

ggplot(df, aes(x, y)) +
  geom_point() +
  geom_text(aes(label = y), position = position_nudge(y = -0.1))

# Or, in brief
ggplot(df, aes(x, y)) +
  geom_point() +
  geom_text(aes(label = y), nudge_y = -0.1)
}
\seealso{
Other position adjustments: 
\code{\link{position_dodge}()},
\code{\link{position_identity}()},
\code{\link{position_jitter}()},
\code{\link{position_jitterdodge}()},
\code{\link{position_stack}()}
}
\concept{position adjustments}