Skip to content

Commit cf82517

Browse files
committed
Merge tag 'v1.0.0'
Release 1.0.0 of ggplot2 Conflicts: R/facet-labels.r man/labeller.Rd
2 parents c383670 + 4760a71 commit cf82517

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+299
-234
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ visual_test
44
^\.travis\.yml$
55
^/\.gitattributes$
66
^inst/web$
7+
^notes$

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ggplot2
22
Type: Package
33
Title: An implementation of the Grammar of Graphics
4-
Version: 0.9.3.1.99
4+
Version: 1.0.0
55
Author: Hadley Wickham <[email protected]>, Winston Chang <[email protected]>
66
Maintainer: Hadley Wickham <[email protected]>
77
Description: An implementation of the grammar of graphics

NEWS

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
1-
ggplot2 0.9.3.1.99
1+
ggplot2 1.0.0
22
----------------------------------------------------------------
33

4-
* New `aes_q()` function to generate aesthetic specifications from
5-
quoted calls/names. `aes_string()` uses names `x` and `y` for first
6-
two unnamed arguments.
7-
8-
* Marginal improvements to `theme_bw` and `theme_classic` (@jiho, #934)
9-
10-
* `stat_ellipse()` adds data ellipses. It supports bivariate normal and t distributions,
11-
as well as a euclidian distance circle. (@jofrhwld, #926)
12-
13-
* Add new themes: `theme_linedraw()` is similar to `theme_bw()` but with
14-
truly only white and black elements and spacing between elements identical
15-
to `theme_gray`. `theme_light` is similar but with light gray box and axes
16-
around the plot, to emphasise content more (@jiho, #923)
17-
18-
* Allow to use brewer palettes for continuous scales, through the new
19-
`scale_fill/colour_distiller()` functions (@jiho, #925).
20-
21-
* `position_jitterdodge()` combines `position_jitter()` and `position_dodge()`,
22-
allowing the user to plot and align points generated by e.g. `geom_point()`
23-
with those generated by a dodged `geom_boxplot()`. See
24-
`example(position_jitterdodge)` for a potential usage. (@kevinushey, #932)
4+
NEW FEATURES
255

266
* New coordinate system for small scale maps. `coord_quickmap()` computes and
277
sets the correct aspect ratio between one degree of latitude and one degree
@@ -34,22 +14,27 @@ ggplot2 0.9.3.1.99
3414
the width of boxplots should be proportional to the size of the groups
3515
(@tsieger, #927).
3616

17+
* `position_jitterdodge()` combines `position_jitter()` and `position_dodge()`,
18+
allowing the user to plot and align points generated by e.g. `geom_point()`
19+
with those generated by a dodged `geom_boxplot()`. See
20+
`example(position_jitterdodge)` for a potential usage. (@kevinushey, #932)
21+
3722
* Allow specifying only one of the limits in a scale and use the automatic
3823
calculation of the other limit by passing NA to to the limit function,
3924
`xlim()` or `ylim()` (@jimhester, #557).
4025

41-
* `geom_dotplot` now works with qplot. (@rasmusab. Fixes #825)
42-
43-
* `stat_smooth()` checks for `method = "auto"` and `method = "glm"` in
44-
a safer way.
26+
* Allow to use brewer palettes for continuous scales, through the new
27+
`scale_fill/colour_distiller()` functions (@jiho, #925).
4528

46-
* `ggpcp()`, `ggfluctuation()`, `ggmissing()`, `ggstructure()`, and
47-
`ggorder()` are now defunct and have been removed.
29+
* `stat_ellipse()` adds data ellipses. It supports bivariate normal and t distributions,
30+
as well as a euclidian distance circle. (@jofrhwld, #926)
4831

49-
* `fortify.SpatialPolygonsDataFrame()` now calls `polygons` without
50-
requiring the `sp` to be loaded first (@seancarmody, #879).
32+
* Add new themes: `theme_linedraw()` is similar to `theme_bw()` but with
33+
truly only white and black elements and spacing between elements identical
34+
to `theme_gray`. `theme_light` is similar but with light gray box and axes
35+
around the plot, to emphasise content more (@jiho, #923)
5136

52-
* theme: new theme settings panel.margin.x and panel.margin.y (units) allow
37+
* new theme settings panel.margin.x and panel.margin.y (units) allow
5338
specifying horizontal and vertical gap between panels in facetted plots (for
5439
both grid and wrap). (Kirill Müller. Fixes #839)
5540

@@ -59,23 +44,43 @@ ggplot2 0.9.3.1.99
5944
and `hjust` is now the same for both rotated and non-rotated text elements
6045
(0 = top/left, 1 = bottom/right, 0.5 = centered). (@krlmlr, #883)
6146

47+
* Added helper function `labeller()` for formatting faceting values.
48+
(@stefanedwards, #910). Added `label_wrap_gen` based on
49+
https://github.com/hadley/ggplot2/wiki/labeller#writing-new-labellers
50+
(@stefanedwards, #910)
51+
52+
BUG FIXES AND MINOR IMPROVEMENTS
53+
6254
* `aes()` no more treats variables like `a..x..b as a calculated aesthetic.
6355
(@krlmlr, #834.)
6456

57+
* New `aes_q()` function to generate aesthetic specifications from
58+
quoted calls/names. `aes_string()` uses names `x` and `y` for first
59+
two unnamed arguments.
60+
61+
* `fortify.SpatialPolygonsDataFrame()` now calls `polygons` without
62+
requiring the `sp` to be loaded first (@seancarmody, #879).
63+
64+
* The outliers of `geom_boxplot()` use the default colour, size and shape from
65+
`geom_point()`. Changing the defaults of `geom_point()` with
66+
`update_geom_defaults()` will apply the same changes to the outliers of
67+
`geom_boxplot()`. Changing the defaults for the outliers was previously not
68+
possible. (@ThierryO, #757)
69+
70+
* `geom_dotplot()` now works with `qplot()`. (@rasmusab. Fixes #825)
71+
72+
* Marginal improvements to `theme_bw()` and `theme_classic()` (@jiho, #934)
73+
74+
* `stat_smooth()` checks for `method = "auto"` and `method = "glm"` in
75+
a safer way.
76+
6577
* Add `"none"` to documentation of `theme()` for parameter `legend.position`
6678
(@krlmlr, #829).
6779

68-
* The outliers of geom_boxplot() use the default colour, size and shape from
69-
geom_point(). Changing the defaults of geom_point() with
70-
update_geom_defaults() will apply the same changes to the outliers of
71-
geom_boxplot(). Changing the defaults for the outliers was previously not
72-
possible. (@ThierryO, #757)
73-
* Added helper function `labeller` for formatting faceting values.
74-
(@stefanedwards, #910)
80+
REMOVED FUNCTIONALITY
7581

76-
* Added `label_wrap_gen` based on
77-
https://github.com/hadley/ggplot2/wiki/labeller#writing-new-labellers
78-
(@stefanedwards, #910)
82+
* `ggpcp()`, `ggfluctuation()`, `ggmissing()`, `ggstructure()`, and
83+
`ggorder()` are now defunct and have been removed.
7984

8085
ggplot2 0.9.3.1
8186
----------------------------------------------------------------

R/aes-position.r

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,29 @@
2020
#' # generate sample data
2121
#' library(plyr)
2222
#' abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
23-
#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%", middle = "50%", upper = "75%", ymax = "100%"))
23+
#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%",
24+
#' middle = "50%", upper = "75%", ymax = "100%"))
2425
#' b + geom_boxplot(stat = "identity")
2526
#'
2627
#' # Using annotate
2728
#' p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
28-
#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25, fill = "dark grey", alpha = .5)
29+
#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25,
30+
#' fill = "dark grey", alpha = .5)
2931
#'
3032
#' # Geom_segment examples
3133
#' library(grid)
32-
#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
33-
#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15), arrow = arrow(length = unit(0.5, "cm")))
34-
#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
34+
#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25),
35+
#' arrow = arrow(length = unit(0.5, "cm")))
36+
#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15),
37+
#' arrow = arrow(length = unit(0.5, "cm")))
38+
#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
39+
#' arrow = arrow(length = unit(0.5, "cm")))
3540
#'
3641
#' # You can also use geom_segment to recreate plot(type = "h") :
3742
#' counts <- as.data.frame(table(x = rpois(100, 5)))
3843
#' counts$x <- as.numeric(as.character(counts$x))
3944
#' with(counts, plot(x, Freq, type = "h", lwd = 10))
4045
#'
41-
#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x, size = I(10))
46+
#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x,
47+
#' size = I(10))
4248
NULL

R/annotation-custom.r

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ NULL
2424
#' # Dummy plot
2525
#' base <- qplot(1:10, 1:10, geom = "blank") + theme_bw()
2626
#' # Adding a table
27-
#' \donttest{
28-
#' require(gridExtra)
27+
#' \donttest{if (require(gridExtra)) {
2928
#' base + annotation_custom(grob = tableGrob(head(iris[ ,1:3])),
3029
#' xmin = 3, xmax = 6, ymin = 2, ymax = 8)
3130
#' # full panel
3231
#' base + annotation_custom(grob = roundrectGrob(),
3332
#' xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
34-
#' }
33+
#' }}
3534
#' # Inset plot
3635
#' g <- ggplotGrob(qplot(1, 1) +
3736
#' theme(plot.background = element_rect(colour = "black")))

R/facet-labels.r

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -61,94 +61,88 @@ label_bquote <- function(expr = beta ^ .(x)) {
6161
eval(substitute(bquote(expr, list(x = x)), list(expr = quoted))))
6262
}
6363
}
64+
globalVariables("x")
65+
6466

6567
#' Label facets with a word wrapped label.
66-
#'
68+
#'
6769
#' Uses \code{\link[base]{strwrap}} for line wrapping.
6870
#' @param width integer, target column width for output.
6971
#' @export
7072
#' @seealso , \code{\link{labeller}}
7173
label_wrap_gen <- function(width = 25) {
7274
function(variable, values) {
73-
vapply(strwrap(as.character(values), width = width, simplify = FALSE),
75+
vapply(strwrap(as.character(values), width = width, simplify = FALSE),
7476
paste, vector('character', 1), collapse = "\n")
7577
}
7678
}
7779

7880
#' Generic labeller function for facets
79-
#'
81+
#'
8082
#' One-step function for providing methods or named character vectors
8183
#' for displaying labels in facets.
82-
#'
84+
#'
8385
#' The provided methods are checked for number of arguments.
84-
#' If the provided method takes less than two
85-
#' (e.g. \code{\link[Hmisc]{capitalize}}),
86+
#' If the provided method takes less than two
87+
#' (e.g. \code{\link[Hmisc]{capitalize}}),
8688
#' the method is passed \code{values}.
87-
#' Else (e.g. \code{\link{label_both}}),
89+
#' Else (e.g. \code{\link{label_both}}),
8890
#' it is passed \code{variable} and \code{values} (in that order).
8991
#' If you want to be certain, use e.g. an anonymous function.
90-
#' If errors are returned such as ``argument ".." is missing, with no default''
92+
#' If errors are returned such as ``argument ".." is missing, with no default''
9193
#' or ``unused argument (variable)'', matching the method's arguments does not
9294
#' work as expected; make a wrapper function.
93-
#'
9495
#'
95-
#' @param ... Named arguments of the form \code{variable=values},
96-
#' where \code{values} could be a vector or method.
97-
#' @param keep.as.numeric logical, default TRUE. When FALSE, converts numeric
96+
#'
97+
#' @param ... Named arguments of the form \code{variable=values},
98+
#' where \code{values} could be a vector or method.
99+
#' @param keep.as.numeric logical, default TRUE. When FALSE, converts numeric
98100
#' values supplied as margins to the facet to characters.
99101
#' @family facet labeller
100-
#' @return Function to supply to
102+
#' @return Function to supply to
101103
#' \code{\link{facet_grid}} for the argument \code{labeller}.
102-
#' @export
104+
#' @export
103105
#' @examples
104-
#'
105-
#' data(mpg)
106-
#'
106+
#' \donttest{
107107
#' p1 <- ggplot(mpg, aes(cty, hwy)) + geom_point()
108-
#'
109-
#'
110108
#' p1 + facet_grid(cyl ~ class, labeller=label_both)
111-
#'
112109
#' p1 + facet_grid(cyl ~ class, labeller=labeller(cyl=label_both))
113-
#'
114-
#' ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point() +
115-
#' facet_grid(vs + am ~ gear, margins=TRUE,
110+
#'
111+
#' ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point() +
112+
#' facet_grid(vs + am ~ gear, margins=TRUE,
116113
#' labeller=labeller(vs=label_both, am=label_both))
117-
#'
118-
#'
119-
#'
120-
#' data(msleep)
114+
#'
121115
#' capitalize <- function(string) {
122116
#' substr(string, 1, 1) <- toupper(substr(string, 1, 1))
123-
#' string
117+
#' string
124118
#' }
125119
#' conservation_status <- c('cd'='Conservation Dependent',
126-
#' 'en'='Endangered',
120+
#' 'en'='Endangered',
127121
#' 'lc'='Least concern',
128-
#' 'nt'='Near Threatened',
122+
#' 'nt'='Near Threatened',
129123
#' 'vu'='Vulnerable',
130124
#' 'domesticated'='Domesticated')
131-
#' ## Source: http://en.wikipedia.org/wiki/Uncyclopedia:Conservation_status
132-
#'
133-
#' p2 <- ggplot(msleep, aes(x=sleep_total, y=awake)) + geom_point()
134-
#' p2 + facet_grid(vore ~ conservation, labeller=labeller(vore=capitalize))
135-
#'
136-
#' p2 + facet_grid(vore ~ conservation,
137-
#' labeller=labeller(vore=capitalize, conservation=conservation_status ))
138-
#'
139-
#' # We could of course have renamed the levels;
140-
#' # then we can apply another nifty function:
141-
#' library(plyr)
142-
#' msleep$conservation2 <- revalue(msleep$conservation, conservation_status)
143-
#'
144-
#' p2 %+% msleep + facet_grid(vore ~ conservation2, labeller=labeller(vore=capitalize))
145-
#'
146-
#' p2 %+% msleep + facet_grid(vore ~ conservation2,
147-
#' labeller=labeller(conservation2=label_wrap_gen(10) ))
148-
#'
125+
#' ## Source: http://en.wikipedia.org/wiki/Uncyclopedia:Conservation_status
126+
#'
127+
#' p2 <- ggplot(msleep, aes(x=sleep_total, y=awake)) + geom_point()
128+
#' p2 + facet_grid(vore ~ conservation, labeller = labeller(vore = capitalize))
129+
#'
130+
#' p2 + facet_grid(vore ~ conservation,
131+
#' labeller=labeller(vore = capitalize, conservation = conservation_status ))
132+
#'
133+
#' # We could of course have renamed the levels;
134+
#' # then we can apply another nifty function
135+
#' msleep$conservation2 <- plyr::revalue(msleep$conservation, conservation_status)
136+
#'
137+
#' p2 %+% msleep +
138+
#' facet_grid(vore ~ conservation2, labeller = labeller(vore = capitalize))
139+
#' p2 %+% msleep +
140+
#' facet_grid(vore ~ conservation2, labeller = labeller(conservation2 =
141+
#' label_wrap_gen(10)))
142+
#' }
149143
labeller <- function(..., keep.as.numeric=FALSE) {
150144
args <- list(...)
151-
145+
152146
function(variable, values) {
153147
if (is.logical(values)) {
154148
values <- as.integer(values) + 1
@@ -157,27 +151,27 @@ labeller <- function(..., keep.as.numeric=FALSE) {
157151
} else if (is.numeric(values) & !keep.as.numeric) {
158152
values <- as.character(values)
159153
}
160-
154+
161155
res <- args[[variable]]
162-
156+
163157
if (is.null(res)) {
164158
# If the facetting margin (i.e. `variable`) was not specified when calling
165159
# labeller, default to use the actual values.
166160
result <- values
167-
161+
168162
} else if (is.function(res)) {
169163
# How should `variable` and `values` be passed to a function? ------------
170-
arguments <- length(formals(res))
164+
arguments <- length(formals(res))
171165
if (arguments < 2) {
172166
result <- res(values)
173167
} else {
174168
result <- res(variable, values)
175-
}
176-
169+
}
170+
177171
} else {
178172
result <- res[values]
179173
}
180-
174+
181175
return(result)
182176
}
183177
}

R/fortify-lm.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#' geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") +
6060
#' geom_smooth(se = FALSE) +
6161
#' geom_point()
62-
#' qplot(.hat, .cooksd, size = .cooksd / .hat, data = mod) + scale_area()
62+
#' qplot(.hat, .cooksd, size = .cooksd / .hat, data = mod) + scale_size_area()
6363
fortify.lm <- function(model, data = model$model, ...) {
6464
infl <- influence(model, do.coef = FALSE)
6565
data$.hat <- infl$hat

R/geom-boxplot.r

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
#' # Using precomputed statistics
9393
#' # generate sample data
9494
#' abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
95-
#' b <- ggplot(abc, aes(x = X1, ymin = `0%`, lower = `25%`, middle = `50%`, upper = `75%`, ymax = `100%`))
95+
#' b <- ggplot(abc, aes(x = X1, ymin = `0%`, lower = `25%`,
96+
#' middle = `50%`, upper = `75%`, ymax = `100%`))
9697
#' b + geom_boxplot(stat = "identity")
9798
#' b + geom_boxplot(stat = "identity") + coord_flip()
9899
#' b + geom_boxplot(aes(fill = X1), stat = "identity")
@@ -112,7 +113,8 @@
112113
geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot",
113114
position = "dodge", outlier.colour = NULL,
114115
outlier.shape = NULL, outlier.size = NULL,
115-
notch = FALSE, notchwidth = .5, ...) {
116+
notch = FALSE, notchwidth = .5, varwidth = FALSE,
117+
...) {
116118

117119
outlier_defaults <- Geom$find('point')$default_aes()
118120

@@ -123,7 +125,7 @@ geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot",
123125
GeomBoxplot$new(mapping = mapping, data = data, stat = stat,
124126
position = position, outlier.colour = outlier.colour,
125127
outlier.shape = outlier.shape, outlier.size = outlier.size, notch = notch,
126-
notchwidth = notchwidth, ...)
128+
notchwidth = notchwidth, varwidth = varwidth, ...)
127129
}
128130

129131
GeomBoxplot <- proto(Geom, {

0 commit comments

Comments
 (0)