8
8
9
9
* ` facet_wrap() ` and ` facet_grid() ` now support ` vars() ` inputs. Like
10
10
` dplyr::vars() ` , this helper quotes its inputs and supports
11
- quasiquotation. For instance you can now supply facetting variables
12
- like this: ` facet_wrap(vars(am, cyl)) ` instead of `facet_wrap( ~ am +
13
- cyl)`. Note that the formula interface is not going away and will
14
- not be deprecated. ` vars() ` is simply meant to make it easier to
15
- create functions around ` facet_wrap() ` and ` facet_grid() ` .
11
+ quasiquotation. For instance, you can now supply facetting variables
12
+ like this: ` facet_wrap(vars(am, cyl)) ` instead of
13
+ ` facet_wrap(~am + cyl)` . Note that the formula interface is not going
14
+ away and will not be deprecated. ` vars() ` is simply meant to make it
15
+ easier to create functions around ` facet_wrap() ` and ` facet_grid() ` .
16
16
17
17
The first two arguments of ` facet_grid() ` become ` rows ` and ` cols `
18
18
and now support ` vars() ` inputs. Note however that we took special
19
19
care to ensure complete backward compatibility. With this change
20
20
` facet_grid(vars(cyl), vars(am, vs)) ` is equivalent to
21
- ` facet_grid(cyl ~ am + vs) ` and ` facet_grid(cols = vars(am, vs)) ` is
21
+ ` facet_grid(cyl ~ am + vs) ` , and ` facet_grid(cols = vars(am, vs)) ` is
22
22
equivalent to ` facet_grid(. ~ am + vs) ` .
23
23
24
24
One nice aspect of the new interface is that you can now easily
25
25
supply names: `facet_grid(vars(Cylinder = cyl), labeller =
26
- label_both)` will give nice label titles to the facets. Of course
26
+ label_both)` will give nice label titles to the facets. Of course,
27
27
those names can be unquoted with the usual tidy eval syntax.
28
28
29
29
### sf
30
30
31
- ggplot2 now has full support for sf with ` geom_sf() ` and ` coord_sf() ` :
31
+ * ggplot2 now has full support for sf with ` geom_sf() ` and ` coord_sf() ` :
32
32
33
- ``` R
34
- nc <- sf :: st_read(system.file(" shape/nc.shp" , package = " sf" ), quiet = TRUE )
35
- ggplot(nc ) +
36
- geom_sf(aes(fill = AREA ))
37
- ```
38
- It supports all simple features, automatically aligns CRS across layer, sets
39
- up correct aspect ratio, and draws a graticule.
33
+ ``` r
34
+ nc <- sf :: st_read(system.file(" shape/nc.shp" , package = " sf" ), quiet = TRUE )
35
+ ggplot(nc ) +
36
+ geom_sf(aes(fill = AREA ))
37
+ ```
38
+ It supports all simple features, automatically aligns CRS across layer, sets
39
+ up correct aspect ratio, and draws a graticule.
40
40
41
41
## New features
42
42
43
43
* ggplot2 now works on R 3.1 onwards, and uses the
44
44
[ vdiffr] ( https://github.com/lionel-/vdiffr ) package for visual testing.
45
45
46
- * In most cases, accidentally ` %>% ` instead of ` + ` will generate an informative
47
- error (#2400 ).
46
+ * In most cases, accidentally using ` %>% ` instead of ` + ` will generate an
47
+ informative error (#2400 ).
48
48
49
49
* New syntax for calculated aesthetics. Instead of using ` aes(y = ..count..) `
50
50
you can (and should!) use ` aes(y = calc(count)) ` . ` calc() ` is a real function
51
51
with documentation which hopefully will make this part of ggplot2 less
52
- confusing. (#2059 )
52
+ confusing (#2059 ).
53
53
54
- ` calc() ` is particularly nice if for more complex calculation because you
54
+ ` calc() ` is particularly nice for more complex calculation because you
55
55
only need to specify once: ` aes(y = calc(count / max(count))) ` ,
56
56
rather than ` aes(y = ..count.. / max(..count..)) `
57
57
58
58
* New ` tag ` label for adding identification tags to the plot, typically used
59
59
for labelling a subplot with a letter. Add a tag with with ` labs(tag = "A") ` ,
60
- style with the the ` plot.tag ` theme element, and control position with
60
+ style it with the ` plot.tag ` theme element, and control position with the
61
61
` plot.tag.position ` theme setting (@thomasp85 ).
62
62
63
63
### Layers: geoms, stats, and position adjustments
64
64
65
65
* ` geom_segment() ` and ` geom_curve() ` have a new ` arrow.fill ` parameter which
66
- allows you to specify a separate fill colour for closed arrowheads.
66
+ allows you to specify a separate fill colour for closed arrowheads
67
67
(@hrbrmstr and @clauswilke , #2375 ).
68
68
69
69
* ` geom_point() ` and friends can now take shapes as strings instead of integers,
70
- e.g. ` geom_point(shape = "diamond") ` . (@daniel-barnett , #2075 ).
70
+ e.g. ` geom_point(shape = "diamond") ` (@daniel-barnett , #2075 ).
71
71
72
72
* ` position_dodge() ` gains an ` preserve ` argument that allows you to control
73
73
whether the ` total ` width at each ` x ` value is preserved (the current
@@ -76,10 +76,10 @@ up correct aspect ratio, and draws a graticule.
76
76
77
77
* New ` position_dodge2() ` provides enhanced dogding for boxplots. Compared to
78
78
` position_dodge() ` , ` position_dodge2() ` compares ` xmin ` and ` xmax ` values
79
- to determin which elements overlap, and spreading overlapping elements evenly
79
+ to determin which elements overlap, spreading overlapping elements evenly
80
80
within the region of overlap. ` position_dodge2() ` is now the default position
81
81
adjustment for ` geom_boxplot() ` , since it handles ` varwidth = TRUE ` , and
82
- it will be considered for other geoms in future
82
+ it will be considered for other geoms in future.
83
83
84
84
The ` padding ` parameter adds a small amount of padding between elements
85
85
(@karawoo , #2143 ) and a ` reverse ` parameter allows you to reverse the order
@@ -109,7 +109,7 @@ up correct aspect ratio, and draws a graticule.
109
109
wants to have the bottom of the bars being flush with the x axis but
110
110
still leave some (automatically calculated amount of) space above them:
111
111
112
- ``` R
112
+ ``` r
113
113
ggplot(mtcars ) +
114
114
geom_bar(aes(x = factor (cyl ))) +
115
115
scale_y_continuous(expand = expand_scale(mult = c(0 , .1 )))
@@ -120,9 +120,9 @@ up correct aspect ratio, and draws a graticule.
120
120
upper limit unspecified (and perhaps differing between panels ),
121
121
but with some extra space above the highest point on the line.
122
122
(With symmetrical limits , the extra space above the highest point
123
- could in some cases cause the lower limit to be negative. )
123
+ could in some cases cause the lower limit to be negative ) .
124
124
125
- The old syntax for the `expand` argument will of course continue
125
+ The old syntax for the `expand` argument will , of course , continue
126
126
to work. (@ huftis , # 1669)
127
127
128
128
* `scale_colour_continuous()` and `scale_colour_gradient()` are now controlled
@@ -131,7 +131,7 @@ up correct aspect ratio, and draws a graticule.
131
131
132
132
* New `scale_colour_viridis_c()` / `scale_fill_viridis_c()` (continuous ) and
133
133
`scale_colour_viridis_d()` / `scale_fill_viridis_d()` (discrete ) make it
134
- easy to use Viridis colour scales. (@ karawoo , # 1526).
134
+ easy to use Viridis colour scales (@ karawoo , # 1526).
135
135
136
136
* Guides for `geom_text()` now accept custom labels with
137
137
`guide_legend(override.aes = list(label = "foo"))` (@ brianwdavis , # 2458).
@@ -161,24 +161,25 @@ up correct aspect ratio, and draws a graticule.
161
161
defined for the class of the object (@ thomasp85 ).
162
162
163
163
* Theme elements can now be subclassed. Add a `merge_element` method to control
164
- how properties are inherited from parent element. Add `element_grob` method
165
- to define how elements are rendered into grobs (@ thomasp85 , # 1981).
164
+ how properties are inherited from parent element. Add an `element_grob`
165
+ method to define how elements are rendered into grobs (@ thomasp85 , # 1981).
166
166
167
167
* Coords have gained new extension mechanisms.
168
168
169
169
If you have an existing coord extension you will need to revise the
170
- specification of the `train()` method. It is now called `setup_panel_params()`
171
- (better reflecting what it actually does ) and now has arguments
172
- `scale_x` , and `scale_y` (the x and y scales respectively ) and
173
- `param` , a list of plot specific parameters generated by `setup_params()`.
170
+ specification of the `train()` method. It is now called
171
+ `setup_panel_params()` (better reflecting what it actually does ) and now
172
+ has arguments `scale_x` , and `scale_y` (the x and y scales respectively )
173
+ and `param` , a list of plot specific parameters generated by
174
+ `setup_params()`.
174
175
175
176
What was formerly called `scale_details` (in coords ), `panel_ranges`
176
177
(in layout ) and `panel_scales` (in geoms ) are now consistently called
177
- `panel_params` (# 1311). These are parameters of the Coord that vary from
178
+ `panel_params` (# 1311). These are parameters of the coord that vary from
178
179
panel to panel.
179
180
180
- * `ggplot_build()` and `ggplot_gtable()` are now generics so ggplot - subclasses can
181
- define additional behavior during the build stage.
181
+ * `ggplot_build()` and `ggplot_gtable()` are now generics , so ggplot - subclasses
182
+ can define additional behavior during the build stage.
182
183
183
184
* `guide_train()` , `guide_merge()` , `guide_geom()` , and `guide_gengrob()`
184
185
are now exported as they are needed if you want to design your own guide.
@@ -195,24 +196,24 @@ up correct aspect ratio, and draws a graticule.
195
196
convert a list into a data frame. This improves ggplot2 ' s support for
196
197
list-columns (needed for sf support), at a small cost: you can no longer
197
198
use matrix-columns. These are rarely used but are produced by `scale()`;
198
- to continue use `scale()` you' ll need to wrap it with `as.numeric()` ,
199
+ to continue to use `scale()` you' ll need to wrap it with `as.numeric()` ,
199
200
e.g. `as.numeric(scale(x))`.
200
201
201
202
* The function `guide_train()` now has an optional parameter `aesthetic`
202
203
that allows to override the `aesthetic` setting in the scale. This change
203
- will only affect code that implements custom guides. (@ clauswilke )
204
+ will only affect code that implements custom guides (@ clauswilke ).
204
205
205
206
# # Minor bug fixes and improvements
206
207
207
208
# ## Facetting
208
209
209
210
* `facet_grid()` gives a more informative error message if you try to use
210
- a variable in both rows and cols (# 1928)
211
+ a variable in both rows and cols (# 1928).
211
212
212
213
* `facet_grid()` and `facet_wrap()` both give better error messages if you
213
- attempt to use an unsupported coord with free scales (# 2049)
214
+ attempt to use an unsupported coord with free scales (# 2049).
214
215
215
- * `label_parsed()` works once again (# 2279)
216
+ * `label_parsed()` works once again (# 2279).
216
217
217
218
* You can now style the background of horizontal and vertical strips
218
219
independently with `strip.background.x` and `strip.background.y`
@@ -227,7 +228,7 @@ up correct aspect ratio, and draws a graticule.
227
228
228
229
* `scale_identity()` once again produces legends by default (# 2112).
229
230
230
- * Fix bug in secondary axis that would lead to incorrectly placed ticks with
231
+ * Fixed bug in secondary axis that would lead to incorrectly placed ticks with
231
232
strong transforms (@ thomasp85 , # 1992).
232
233
233
234
* Missing line types now reliably generate missing lines (with standard
@@ -238,13 +239,13 @@ up correct aspect ratio, and draws a graticule.
238
239
* All colour and fill scales now have an `aesthetics` argument that can
239
240
be used to set the aesthetic(s ) the scale works with. This makes it
240
241
possible to apply a colour scale to both colour and fill aesthetics
241
- at the same time , via `aesthetics = c(" colour" , " fill" ). (@ clauswilke )
242
+ at the same time , via `aesthetics = c("colour", "fill")` (@ clauswilke ).
242
243
243
244
* Three generic scales were added that work with any aesthetic or set of
244
- aesthetics : `scale_continuous_identity()` , `scale_discrete_identity()` ,
245
- `scale_discrete_manual()` . (@ clauswilke )
245
+ aesthetics : `scale_continuous_identity()` , `scale_discrete_identity()` , and
246
+ `scale_discrete_manual()` (@ clauswilke ).
246
247
247
- * Fix bug in `scale_*_gradient2()` where points outside limits can sometimes
248
+ * Fixed bug in `scale_*_gradient2()` where points outside limits can sometimes
248
249
reappear due to rescaling. Now , any rescaling is performed after the limits
249
250
are enforced (@ foo - bar - baz - qux , # 2230).
250
251
@@ -280,44 +281,45 @@ up correct aspect ratio, and draws a graticule.
280
281
with stats other than the default (@ clauswilke , # 1546).
281
282
282
283
* `geom_tile()` now once again interprets `width` and `height` correctly
283
- (@ malcolmbarrett , # 2510)
284
+ (@ malcolmbarrett , # 2510).
284
285
285
286
* `position_jitter()` and `position_jitterdodge()` gain a `seed` argument that
286
- allows specifying a random seed for reproducible jittering ( @ krlmlr , # 1996
287
- and @ slowkow , # 2445).
287
+ allows the specification of a random seed for reproducible jittering
288
+ ( @ krlmlr , # 1996 and @slowkow, #2445).
288
289
289
290
* `stat_density()` has better behaviour if all groups are dropped because they
290
291
are too small (# 2282).
291
292
292
- * `stat_summary_bin()` now understands the `breaks` parameter (@ karawoo , # 2214)
293
+ * `stat_summary_bin()` now understands the `breaks` parameter (@ karawoo , # 2214).
293
294
294
295
* `stat_bin()` now accepts functions for `binwidth`. This allows better binning
295
296
when faceting along variables with different ranges (@ botanize ).
296
297
297
298
* `stat_bin()` / `geom_histogram()` no longer sum incorrectly when using the
298
299
`weight` aesthetic (@ jiho , # 1921).
299
300
300
- * `stat_bin()` uses correct scaling for computed variable `ndensity` (@ timgoodman , # 2324)
301
+ * `stat_bin()` uses correct scaling for computed variable `ndensity`
302
+ (@ timgoodman , # 2324).
301
303
302
- * `stat_bin()` and `stat_bin_2d()` now properly handle the `breaks` parameter when
303
- the scales are transformed (@ has2k1 , # 2366).
304
+ * `stat_bin()` and `stat_bin_2d()` now properly handle the `breaks` parameter
305
+ when the scales are transformed (@ has2k1 , # 2366).
304
306
305
307
* `update_geom_defaults()` and `update_stat_defaults()` allow American
306
308
spelling of aesthetic parameters (@ foo - bar - baz - qux , # 2299).
307
309
308
310
* The `show.legend` parameter now accepts a named logical vector to hide / show
309
- only some aesthetics in the legend (@ tutuchan , # 1798)
311
+ only some aesthetics in the legend (@ tutuchan , # 1798).
310
312
311
313
* Layers no longer warn about unknown aesthetics with value `NULL` (# 1909).
312
314
313
315
# ## Coords
314
316
315
317
* Clipping to the plot panel is now configurable , through a `clip` argument
316
- to coordinate systems , e.g. `coord_cartesian(clip = "off")`.
317
- (@ clauswilke , # 2536)
318
+ to coordinate systems , e.g. `coord_cartesian(clip = "off")`
319
+ (@ clauswilke , # 2536).
318
320
319
321
* Like scales , coordinate systems now give you a message when you ' re
320
- replacing an existing coordiante system (#2264)
322
+ replacing an existing coordiante system (#2264).
321
323
322
324
* `coord_polar()` now draws secondary axis ticks and labels
323
325
(@dylan-stark, #2072), and can draw the radius axis on the right
@@ -329,7 +331,7 @@ up correct aspect ratio, and draws a graticule.
329
331
### Themes
330
332
331
333
* Complete themes now always override all elements of the default theme
332
- (@has2k1, #2058, #2079)
334
+ (@has2k1, #2058, #2079).
333
335
334
336
* Themes now set default grid colour in `panel.grid` rather than individually
335
337
in `panel.grid.major` and `panel.grid.minor` individually. This makes it
@@ -338,43 +340,43 @@ up correct aspect ratio, and draws a graticule.
338
340
* Fixed bug when setting strips to `element_blank()` (@thomasp85).
339
341
340
342
* Axes positioned on the top and to the right can now customize their ticks and
341
- lines separately (@thomasp85, #1899)
343
+ lines separately (@thomasp85, #1899).
342
344
343
345
* Built-in themes gain parameters `base_line_size` and `base_rect_size` which
344
346
control the default sizes of line and rectangle elements (@karawoo, #2176).
345
347
346
348
* Default themes use `rel()` to set line widths (@baptiste).
347
349
348
- * Themes were tweaked for visual consistency and more graceful behavior when changing
349
- the base font size. All absolute heights or widths were replaced with heights or
350
- widths that are proportional to the base font size. One relative font size
351
- was eliminated. (@clauswilke)
350
+ * Themes were tweaked for visual consistency and more graceful behavior when
351
+ changing the base font size. All absolute heights or widths were replaced
352
+ with heights or widths that are proportional to the base font size. One
353
+ relative font size was eliminated (@clauswilke).
352
354
353
355
* The height of descenders is now calculated solely on font metrics and doesn' t
354
356
change with the specific letters in the string. This fixes minor alignment
355
- issues with plot titles , subtitles , and legend titles. (# 2288, @clauswilke)
357
+ issues with plot titles , subtitles , and legend titles (# 2288, @clauswilke).
356
358
357
359
# ## Guides
358
360
359
361
* `guide_colorbar()` is more configurable : tick marks and color bar frame
360
362
can now by styled with arguments `ticks.colour` , `ticks.linewidth` ,
361
- `frame.colour` , `frame.linewidth` , and `frame.linetype`.
362
- (@ clauswilke )
363
+ `frame.colour` , `frame.linewidth` , and `frame.linetype`
364
+ (@ clauswilke ).
363
365
364
366
* `guide_colorbar()` now uses `legend.spacing.x` and `legend.spacing.y`
365
367
correctly , and it can handle multi - line titles. Minor tweaks were made to
366
368
`guide_legend()` to make sure the two legend functions behave as similarly as
367
- possible. (@ clauswilke , # 2397 and #2398)
369
+ possible (@ clauswilke , # 2397 and #2398).
368
370
369
371
* The theme elements `legend.title` and `legend.text` now respect the settings
370
- of `margin` , `hjust` , and `vjust` . (@ clauswilke , # 2465, #1502)
372
+ of `margin` , `hjust` , and `vjust` (@ clauswilke , # 2465, #1502).
371
373
372
374
* Non - angle parameters of `label.theme` or `title.theme` can now be set in
373
- `guide_legend()` and `guide_colorbar()` . (@ clauswilke , # 2544)
375
+ `guide_legend()` and `guide_colorbar()` (@ clauswilke , # 2544).
374
376
375
377
# ## Other
376
378
377
- * `fortify()` gains a method for tbls (@ karawoo , # 2218)
379
+ * `fortify()` gains a method for tbls (@ karawoo , # 2218).
378
380
379
381
* `ggplot` gains a method for `grouped_df`s that adds a `.group` variable ,
380
382
which computes a unique value for each group. Use it with
@@ -388,20 +390,20 @@ up correct aspect ratio, and draws a graticule.
388
390
DPI), "print" (300 DPI), and "screen" (72 DPI) (@foo-bar-baz-qux, #2156).
389
391
`ggsave()` no longer partially matches graphic device parameters (#2355),
390
392
and correctly restores the previous graphics device when several
391
- graphics devices are open. (#2363)
393
+ graphics devices are open (#2363).
392
394
393
395
* `print.ggplot()` now returns the original ggplot object, instead of the
394
396
output from `ggplot_build()`. Also, the object returned from
395
- `ggplot_build()` now has the class `"ggplot_built"`. (#2034)
397
+ `ggplot_build()` now has the class `"ggplot_built"` (#2034).
396
398
397
- * `map_data()` now works even when purrr is loaded (tidyverse#66)
399
+ * `map_data()` now works even when purrr is loaded (tidyverse#66).
398
400
399
401
* New functions `summarise_layout()`, `summarise_coord()`, and
400
402
`summarise_layers()` summarise the layout, coordinate systems, and layers,
401
403
of a built ggplot object (#2034, @wch). This provides a tested API that
402
404
(e.g.) shiny can depend on.
403
405
404
- * Update startup messages to reflect new resources. (#2410, @mine-cetinkaya-rundel)
406
+ * Updated startup messages reflect new resources (#2410, @mine-cetinkaya-rundel).
405
407
406
408
# ggplot2 2.2.1
407
409
0 commit comments