Skip to content

Commit c48afd0

Browse files
committed
document
1 parent d2fb415 commit c48afd0

File tree

5 files changed

+200
-5
lines changed

5 files changed

+200
-5
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Collate:
247247
'stat-bindot.R'
248248
'stat-binhex.R'
249249
'stat-boxplot.R'
250+
'stat-connect.R'
250251
'stat-contour.R'
251252
'stat-count.R'
252253
'stat-density-2d.R'

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ export(StatBin2d)
257257
export(StatBindot)
258258
export(StatBinhex)
259259
export(StatBoxplot)
260+
export(StatConnect)
260261
export(StatContour)
261262
export(StatContourFilled)
262263
export(StatCount)
@@ -684,6 +685,7 @@ export(stat_bin_2d)
684685
export(stat_bin_hex)
685686
export(stat_binhex)
686687
export(stat_boxplot)
688+
export(stat_connect)
687689
export(stat_contour)
688690
export(stat_contour_filled)
689691
export(stat_count)

R/stat-connect.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
#' Connect observations
2+
#'
3+
#' Connect successive points with lines of different shapes.
4+
#'
5+
#' @inheritParams layer
6+
#' @inheritParams geom_point
7+
#' @param connection A specification of how two points are connected. Can be one
8+
#' of the folloing:
9+
#' * A string giving a named connection. These options are:
10+
#' * `"hv"` to first jump horizontally, then vertically.
11+
#' * `"vh"` to first jump vertically, then horizontally.
12+
#' * `"mid"` to step half-way between adjacent x-values.
13+
#' * `"linear"` to use a straight segment.
14+
#' * A numeric matrix with two columns giving x and y coordinates respectively.
15+
#' The coordinates should describe points on a path that connect point A
16+
#' at location (0, 0) and point B at location (1, 1). At least one of these
17+
#' two points is expected to be included in the coordinates.
18+
#'
19+
#' @eval rd_aesthetics("stat", "connect")
20+
#' @export
21+
#'
22+
#' @examples
23+
#' ggplot(head(economics, 20), aes(date, unemploy)) +
24+
#' stat_connect(connection = "hv")
25+
#'
26+
#' # Setup custom connections
27+
#' x <- seq(0, 1, length.out = 20)[-1]
28+
#' smooth <- cbind(x, scales::rescale(1 / (1 + exp(-(x * 10 - 5)))))
29+
#' zigzag <- cbind(c(0.4, 0.6, 1), c(0.75, 0.25, 1))
30+
#'
31+
#' ggplot(head(economics, 10), aes(date, unemploy)) +
32+
#' geom_point() +
33+
#' stat_connect(aes(colour = "zigzag"), connection = zigzag) +
34+
#' stat_connect(aes(colour = "smooth"), connection = smooth)
135
stat_connect <- function(
236
mapping = NULL,
337
data = NULL,
@@ -24,6 +58,10 @@ stat_connect <- function(
2458
)
2559
}
2660

61+
#' @rdname ggplot2-ggproto
62+
#' @format NULL
63+
#' @usage NULL
64+
#' @export
2765
StatConnect <- ggproto(
2866
"StatConnect", Stat,
2967

man/ggplot2-ggproto.Rd

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/stat_connect.Rd

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)