Skip to content

Commit ea3b3ce

Browse files
committed
Update news and update documentation
1 parent 6744184 commit ea3b3ce

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ ggplot2 0.9.3.1.99
1313
* Add `"none"` to documentation of `theme()` for parameter `legend.position`.
1414
(@krlmlr, #829)
1515

16+
MINOR FEATURES
17+
18+
* Allow specifying only one of the limits in a scale and use the automatic
19+
calculation of the other limit by passing NA to to the limit function (xlim
20+
or ylim). (Fixes #557) Thanks Jim Hester.
1621

1722
ggplot2 0.9.3.1
1823
----------------------------------------------------------------

R/limits.r

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#' Convenience functions to set the limits of the x and y axis.
22
#'
33
#' Observations not in this range will be dropped completely and
4-
#' not passed to any other layers.
4+
#' not passed to any other layers. If a NA value is substituted for one of the
5+
#' limits that limit is automatically calculated.
56
#'
67
#' @param ... if numeric, will create a continuous scale, if factor or
78
#' character, will create a discrete scale.
@@ -16,12 +17,16 @@
1617
#' xlim(c(10, 20))
1718
#' xlim("a", "b", "c")
1819
#' qplot(mpg, wt, data=mtcars) + xlim(15, 20)
20+
#' # with automatic lower limit
21+
#' qplot(mpg, wt, data=mtcars) + xlim(NA, 20)
1922
#'
2023
#' # ylim
2124
#' ylim(15, 20)
2225
#' ylim(c(10, 20))
2326
#' ylim("a", "b", "c")
2427
#' qplot(mpg, wt, data=mtcars) + ylim(15, 20)
28+
#' # with automatic upper limit
29+
#' qplot(mpg, wt, data=mtcars) + ylim(15, NA)
2530
xlim <- function(...) {
2631
limits(c(...), "x")
2732
}

man/xylim.Rd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ ylim(...)
1414
}
1515
\description{
1616
Observations not in this range will be dropped completely and
17-
not passed to any other layers.
17+
not passed to any other layers. If a NA value is substituted for one of the
18+
limits that limit is automatically calculated.
1819
}
1920
\examples{
2021
# xlim
@@ -23,12 +24,16 @@ xlim(20, 15)
2324
xlim(c(10, 20))
2425
xlim("a", "b", "c")
2526
qplot(mpg, wt, data=mtcars) + xlim(15, 20)
27+
# with automatic lower limit
28+
qplot(mpg, wt, data=mtcars) + xlim(NA, 20)
2629

2730
# ylim
2831
ylim(15, 20)
2932
ylim(c(10, 20))
3033
ylim("a", "b", "c")
3134
qplot(mpg, wt, data=mtcars) + ylim(15, 20)
35+
# with automatic upper limit
36+
qplot(mpg, wt, data=mtcars) + ylim(15, NA)
3237
}
3338
\seealso{
3439
For changing x or y axis limits \strong{without} dropping data

0 commit comments

Comments
 (0)