File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ ggplot2 0.9.3.1.99
13
13
* Add `"none"` to documentation of `theme()` for parameter `legend.position`.
14
14
(@krlmlr, #829)
15
15
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.
16
21
17
22
ggplot2 0.9.3.1
18
23
----------------------------------------------------------------
Original file line number Diff line number Diff line change 1
1
# ' Convenience functions to set the limits of the x and y axis.
2
2
# '
3
3
# ' 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.
5
6
# '
6
7
# ' @param ... if numeric, will create a continuous scale, if factor or
7
8
# ' character, will create a discrete scale.
16
17
# ' xlim(c(10, 20))
17
18
# ' xlim("a", "b", "c")
18
19
# ' qplot(mpg, wt, data=mtcars) + xlim(15, 20)
20
+ # ' # with automatic lower limit
21
+ # ' qplot(mpg, wt, data=mtcars) + xlim(NA, 20)
19
22
# '
20
23
# ' # ylim
21
24
# ' ylim(15, 20)
22
25
# ' ylim(c(10, 20))
23
26
# ' ylim("a", "b", "c")
24
27
# ' qplot(mpg, wt, data=mtcars) + ylim(15, 20)
28
+ # ' # with automatic upper limit
29
+ # ' qplot(mpg, wt, data=mtcars) + ylim(15, NA)
25
30
xlim <- function (... ) {
26
31
limits(c(... ), " x" )
27
32
}
Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ ylim(...)
14
14
}
15
15
\description {
16
16
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.
18
19
}
19
20
\examples {
20
21
# xlim
@@ -23,12 +24,16 @@ xlim(20, 15)
23
24
xlim(c(10 , 20 ))
24
25
xlim(" a" , " b" , " c" )
25
26
qplot(mpg , wt , data = mtcars ) + xlim(15 , 20 )
27
+ # with automatic lower limit
28
+ qplot(mpg , wt , data = mtcars ) + xlim(NA , 20 )
26
29
27
30
# ylim
28
31
ylim(15 , 20 )
29
32
ylim(c(10 , 20 ))
30
33
ylim(" a" , " b" , " c" )
31
34
qplot(mpg , wt , data = mtcars ) + ylim(15 , 20 )
35
+ # with automatic upper limit
36
+ qplot(mpg , wt , data = mtcars ) + ylim(15 , NA )
32
37
}
33
38
\seealso {
34
39
For changing x or y axis limits \strong {without } dropping data
You can’t perform that action at this time.
0 commit comments