1# ggplot2 3.3.5 2This is a very small release focusing on fixing a couple of untenable issues 3that surfaced with the 3.3.4 release 4 5* Revert changes made in #4434 (apply transform to intercept in `geom_abline()`) 6 as it introduced undesirable issues far worse than the bug it fixed 7 (@thomasp85, #4514) 8* Fixes an issue in `ggsave()` when producing emf/wmf files (@yutannihilation, 9 #4521) 10* Warn when grDevices specific arguments are passed to ragg devices (@thomasp85, 11 #4524) 12* Fix an issue where `coord_sf()` was reporting that it is non-linear 13 even when data is provided in projected coordinates (@clauswilke, #4527) 14 15# ggplot2 3.3.4 16This is a larger patch release fixing a huge number of bugs and introduces a 17small selection of feature refinements. 18 19## Features 20 21* Alt-text can now be added to a plot using the `alt` label, i.e 22 `+ labs(alt = ...)`. Currently this alt text is not automatically propagated, 23 but we plan to integrate into Shiny, RMarkdown, and other tools in the future. 24 (@thomasp85, #4477) 25 26* Add support for the BrailleR package for creating descriptions of the plot 27 when rendered (@thomasp85, #4459) 28 29* `coord_sf()` now has an argument `default_crs` that specifies the coordinate 30 reference system (CRS) for non-sf layers and scale/coord limits. This argument 31 defaults to `NULL`, which means non-sf layers are assumed to be in projected 32 coordinates, as in prior ggplot2 versions. Setting `default_crs = sf::st_crs(4326)` 33 provides a simple way to interpret x and y positions as longitude and latitude, 34 regardless of the CRS used by `coord_sf()`. Authors of extension packages 35 implementing `stat_sf()`-like functionality are encouraged to look at the source 36 code of `stat_sf()`'s `compute_group()` function to see how to provide scale-limit 37 hints to `coord_sf()` (@clauswilke, #3659). 38 39* `ggsave()` now uses ragg to render raster output if ragg is available. It also 40 handles custom devices that sets a default unit (e.g. `ragg::agg_png`) 41 correctly (@thomasp85, #4388) 42 43* `ggsave()` now returns the saved file location invisibly (#3379, @eliocamp). 44 Note that, as a side effect, an unofficial hack `<ggplot object> + ggsave()` 45 no longer works (#4513). 46 47* The scale arguments `limits`, `breaks`, `minor_breaks`, `labels`, `rescaler` 48 and `oob` now accept purrr style lambda notation (@teunbrand, #4427). The same 49 is true for `as_labeller()` (and therefore also `labeller()`) 50 (@netique, #4188). 51 52* Manual scales now allow named vectors passed to `values` to contain fewer 53 elements than existing in the data. Elements not present in values will be set 54 to `NA` (@thomasp85, #3451) 55 56* Date and datetime position scales support out-of-bounds (oob) arguments to 57 control how limits affect data outside those limits (@teunbrand, #4199). 58 59## Fixes 60 61* Fix a bug that `after_stat()` and `after_scale()` cannot refer to aesthetics 62 if it's specified in the plot-global mapping (@yutannihilation, #4260). 63 64* Fix bug in `annotate_logticks()` that would cause an error when used together 65 with `coord_flip()` (@thomasp85, #3954) 66 67* Fix a bug in `geom_abline()` that resulted in `intercept` not being subjected 68 to the transformation of the y scale (@thomasp85, #3741) 69 70* Extent the range of the line created by `geom_abline()` so that line ending 71 is not visible for large linewidths (@thomasp85, #4024) 72 73* Fix bug in `geom_dotplot()` where dots would be positioned wrong with 74 `stackgroups = TRUE` (@thomasp85, #1745) 75 76* Fix calculation of confidence interval for locfit smoothing in `geom_smooth()` 77 (@topepo, #3806) 78 79* Fix bug in `geom_text()` where `"outward"` and `"inward"` justification for 80 some `angle` values was reversed (@aphalo, #4169, #4447) 81 82* `ggsave()` now sets the default background to match the fill value of the 83 `plot.background` theme element (@karawoo, #4057) 84 85* It is now deprecated to specify `guides(<scale> = FALSE)` or 86 `scale_*(guide = FALSE)` to remove a guide. Please use 87 `guides(<scale> = "none")` or `scale_*(guide = "none")` instead 88 (@yutannihilation, #4094). 89 90* Fix a bug in `guide_bins()` where keys would disappear if the guide was 91 reversed (@thomasp85, #4210) 92 93* Fix bug in `guide_coloursteps()` that would repeat the terminal bins if the 94 breaks coincided with the limits of the scale (@thomasp85, #4019) 95 96* Make sure that default labels from default mappings doesn't overwrite default 97 labels from explicit mappings (@thomasp85, #2406) 98 99* Fix bug in `labeller()` where parsing was turned off if `.multiline = FALSE` 100 (@thomasp85, #4084) 101 102* Make sure `label_bquote()` has access to the calling environment when 103 evaluating the labels (@thomasp85, #4141) 104 105* Fix a bug in the layer implementation that introduced a new state after the 106 first render which could lead to a different look when rendered the second 107 time (@thomasp85, #4204) 108 109* Fix a bug in legend justification where justification was lost of the legend 110 dimensions exceeded the available size (@thomasp85, #3635) 111 112* Fix a bug in `position_dodge2()` where `NA` values in thee data would cause an 113 error (@thomasp85, #2905) 114 115* Make sure `position_jitter()` creates the same jittering independent of 116 whether it is called by name or with constructor (@thomasp85, #2507) 117 118* Fix a bug in `position_jitter()` where different jitters would be applied to 119 different position aesthetics of the same axis (@thomasp85, #2941) 120 121* Fix a bug in `qplot()` when supplying `c(NA, NA)` as axis limits 122 (@thomasp85, #4027) 123 124* Remove cross-inheritance of default discrete colour/fill scales and check the 125 type and aesthetic of function output if `type` is a function 126 (@thomasp85, #4149) 127 128* Fix bug in `scale_[x|y]_date()` where custom breaks functions that resulted in 129 fracional dates would get misaligned (@thomasp85, #3965) 130 131* Fix bug in `scale_[x|y]_datetime()` where a specified timezone would be 132 ignored by the scale (@thomasp85, #4007) 133 134* Fix issue in `sec_axis()` that would throw warnings in the absence of any 135 secondary breaks (@thomasp85, #4368) 136 137* `stat_bin()`'s computed variable `width` is now documented (#3522). 138 139* `stat_count()` now computes width based on the full dataset instead of per 140 group (@thomasp85, #2047) 141 142* Extended `stat_ecdf()` to calculate the cdf from either x or y instead from y 143 only (@jgjl, #4005) 144 145* Fix a bug in `stat_summary_bin()` where one more than the requested number of 146 bins would be created (@thomasp85, #3824) 147 148* Only drop groups in `stat_ydensity()` when there are fewer than two data 149 points and throw a warning (@andrewwbutler, #4111). 150 151* Fixed a bug in strip assembly when theme has `strip.text = element_blank()` 152 and plots are faceted with multi-layered strips (@teunbrand, #4384). 153 154* Using `theme(aspect.ratio = ...)` together with free space in `facet_grid()` 155 now crrectly throws an error (@thomasp85, #3834) 156 157* Fixed a bug in `labeller()` so that `.default` is passed to `as_labeller()` 158 when labellers are specified by naming faceting variables. (@waltersom, #4031) 159 160* Updated style for example code (@rjake, #4092) 161 162* ggplot2 now requires R >= 3.3 (#4247). 163 164* ggplot2 now uses `rlang::check_installed()` to check if a suggested package is 165 installed, which will offer to install the package before continuing (#4375, 166 @malcolmbarrett) 167 168* Improved error with hint when piping a `ggplot` object into a facet function 169 (#4379, @mitchelloharawild). 170 171# ggplot2 3.3.3 172This is a small patch release mainly intended to address changes in R and CRAN. 173It further changes the licensing model of ggplot2 to an MIT license. 174 175* Update the ggplot2 licence to an MIT license (#4231, #4232, #4233, and #4281) 176 177* Use vdiffr conditionally so ggplot2 can be tested on systems without vdiffr 178 179* Update tests to work with the new `all.equal()` defaults in R >4.0.3 180 181* Fixed a bug that `guide_bins()` mistakenly ignore `override.aes` argument 182 (@yutannihilation, #4085). 183 184# ggplot2 3.3.2 185This is a small release focusing on fixing regressions introduced in 3.3.1. 186 187* Added an `outside` option to `annotation_logticks()` that places tick marks 188 outside of the plot bounds. (#3783, @kbodwin) 189 190* `annotation_raster()` adds support for native rasters. For large rasters, 191 native rasters render significantly faster than arrays (@kent37, #3388) 192 193* Facet strips now have dedicated position-dependent theme elements 194 (`strip.text.x.top`, `strip.text.x.bottom`, `strip.text.y.left`, 195 `strip.text.y.right`) that inherit from `strip.text.x` and `strip.text.y`, 196 respectively. As a consequence, some theme stylings now need to be applied to 197 the position-dependent elements rather than to the parent elements. This 198 change was already introduced in ggplot2 3.3.0 but not listed in the 199 changelog. (@thomasp85, #3683) 200 201* Facets now handle layers containing no data (@yutannihilation, #3853). 202 203* A newly added geom `geom_density_2d_filled()` and associated stat 204 `stat_density_2d_filled()` can draw filled density contours 205 (@clauswilke, #3846). 206 207* A newly added `geom_function()` is now recommended to use in conjunction 208 with/instead of `stat_function()`. In addition, `stat_function()` now 209 works with transformed y axes, e.g. `scale_y_log10()`, and in plots 210 containing no other data or layers (@clauswilke, #3611, #3905, #3983). 211 212* Fixed a bug in `geom_sf()` that caused problems with legend-type 213 autodetection (@clauswilke, #3963). 214 215* Support graphics devices that use the `file` argument instead of `fileneame` 216 in `ggsave()` (@bwiernik, #3810) 217 218* Default discrete color scales are now configurable through the `options()` of 219 `ggplot2.discrete.colour` and `ggplot2.discrete.fill`. When set to a character 220 vector of colour codes (or list of character vectors) with sufficient length, 221 these colours are used for the default scale. See `help(scale_colour_discrete)` 222 for more details and examples (@cpsievert, #3833). 223 224* Default continuous colour scales (i.e., the `options()` 225 `ggplot2.continuous.colour` and `ggplot2.continuous.fill`, which inform the 226 `type` argument of `scale_fill_continuous()` and `scale_colour_continuous()`) 227 now accept a function, which allows more control over these default 228 `continuous_scale()`s (@cpsievert, #3827). 229 230* A bug was fixed in `stat_contour()` when calculating breaks based on 231 the `bins` argument (@clauswilke, #3879, #4004). 232 233* Data columns can now contain `Vector` S4 objects, which are widely used in the 234 Bioconductor project. (@teunbrand, #3837) 235 236# ggplot2 3.3.1 237 238This is a small release with no code change. It removes all malicious links to a 239site that got hijacked from the readme and pkgdown site. 240 241# ggplot2 3.3.0 242 243This is a minor release but does contain a range of substantial new features, 244along with the standard bug fixes. The release contains a few visual breaking 245changes, along with breaking changes for extension developers due to a shift in 246internal representation of the position scales and their axes. No user breaking 247changes are included. 248 249This release also adds Dewey Dunnington (@paleolimbot) to the core team. 250 251## Breaking changes 252There are no user-facing breaking changes, but a change in some internal 253representations that extension developers may have relied on, along with a few 254breaking visual changes which may cause visual tests in downstream packages to 255fail. 256 257* The `panel_params` field in the `Layout` now contains a list of list of 258 `ViewScale` objects, describing the trained coordinate system scales, instead 259 of the list object used before. Any extensions that use this field will likely 260 break, as will unit tests that checks aspects of this. 261 262* `element_text()` now issues a warning when vectorized arguments are provided, 263 as in `colour = c("red", "green", "blue")`. Such use is discouraged and not 264 officially supported (@clauswilke, #3492). 265 266* Changed `theme_grey()` setting for legend key so that it creates no border 267 (`NA`) rather than drawing a white one. (@annennenne, #3180) 268 269* `geom_ribbon()` now draws separate lines for the upper and lower intervals if 270 `colour` is mapped. Similarly, `geom_area()` and `geom_density()` now draw 271 the upper lines only in the same case by default. If you want old-style full 272 stroking, use `outline.type = "full"` (@yutannihilation, #3503 / @thomasp85, #3708). 273 274## New features 275 276* The evaluation time of aesthetics can now be controlled to a finer degree. 277 `after_stat()` supersedes the use of `stat()` and `..var..`-notation, and is 278 joined by `after_scale()` to allow for mapping to scaled aesthetic values. 279 Remapping of the same aesthetic is now supported with `stage()`, so you can 280 map a data variable to a stat aesthetic, and remap the same aesthetic to 281 something else after statistical transformation (@thomasp85, #3534) 282 283* All `coord_*()` functions with `xlim` and `ylim` arguments now accept 284 vectors with `NA` as a placeholder for the minimum or maximum value 285 (e.g., `ylim = c(0, NA)` would zoom the y-axis from 0 to the 286 maximum value observed in the data). This mimics the behaviour 287 of the `limits` argument in continuous scale functions 288 (@paleolimbot, #2907). 289 290* Allowed reversing of discrete scales by re-writing `get_limits()` 291 (@AnneLyng, #3115) 292 293* All geoms and stats that had a direction (i.e. where the x and y axes had 294 different interpretation), can now freely choose their direction, instead of 295 relying on `coord_flip()`. The direction is deduced from the aesthetic 296 mapping, but can also be specified directly with the new `orientation` 297 argument (@thomasp85, #3506). 298 299* Position guides can now be customized using the new `guide_axis()`, which can 300 be passed to position `scale_*()` functions or via `guides()`. The new axis 301 guide (`guide_axis()`) comes with arguments `check.overlap` (automatic removal 302 of overlapping labels), `angle` (easy rotation of axis labels), and 303 `n.dodge` (dodge labels into multiple rows/columns) (@paleolimbot, #3322). 304 305* A new scale type has been added, that allows binning of aesthetics at the 306 scale level. It has versions for both position and non-position aesthetics and 307 comes with two new guides (`guide_bins` and `guide_coloursteps`) 308 (@thomasp85, #3096) 309 310* `scale_x_continuous()` and `scale_y_continuous()` gains an `n.breaks` argument 311 guiding the number of automatic generated breaks (@thomasp85, #3102) 312 313* Added `stat_contour_filled()` and `geom_contour_filled()`, which compute 314 and draw filled contours of gridded data (@paleolimbot, #3044). 315 `geom_contour()` and `stat_contour()` now use the isoband package 316 to compute contour lines. The `complete` parameter (which was undocumented 317 and has been unused for at least four years) was removed (@paleolimbot, #3044). 318 319* Themes have gained two new parameters, `plot.title.position` and 320 `plot.caption.position`, that can be used to customize how plot 321 title/subtitle and plot caption are positioned relative to the overall plot 322 (@clauswilke, #3252). 323 324## Extensions 325 326* `Geom` now gains a `setup_params()` method in line with the other ggproto 327 classes (@thomasp85, #3509) 328 329* The newly added function `register_theme_elements()` now allows developers 330 of extension packages to define their own new theme elements and place them 331 into the ggplot2 element tree (@clauswilke, #2540). 332 333## Minor improvements and bug fixes 334 335* `coord_trans()` now draws second axes and accepts `xlim`, `ylim`, 336 and `expand` arguments to bring it up to feature parity with 337 `coord_cartesian()`. The `xtrans` and `ytrans` arguments that were 338 deprecated in version 1.0.1 in favour of `x` and `y` 339 were removed (@paleolimbot, #2990). 340 341* `coord_trans()` now calculates breaks using the expanded range 342 (previously these were calculated using the unexpanded range, 343 which resulted in differences between plots made with `coord_trans()` 344 and those made with `coord_cartesian()`). The expansion for discrete axes 345 in `coord_trans()` was also updated such that it behaves identically 346 to that in `coord_cartesian()` (@paleolimbot, #3338). 347 348* `expand_scale()` was deprecated in favour of `expansion()` for setting 349 the `expand` argument of `x` and `y` scales (@paleolimbot). 350 351* `geom_abline()`, `geom_hline()`, and `geom_vline()` now issue 352 more informative warnings when supplied with set aesthetics 353 (i.e., `slope`, `intercept`, `yintercept`, and/or `xintercept`) 354 and mapped aesthetics (i.e., `data` and/or `mapping`). 355 356* Fix a bug in `geom_raster()` that squeezed the image when it went outside 357 scale limits (#3539, @thomasp85) 358 359* `geom_sf()` now determines the legend type automatically (@microly, #3646). 360 361* `geom_sf()` now removes rows that can't be plotted due to `NA` aesthetics 362 (#3546, @thomasp85) 363 364* `geom_sf()` now applies alpha to linestring geometries 365 (#3589, @yutannihilation). 366 367* `gg_dep()` was deprecated (@perezp44, #3382). 368 369* Added function `ggplot_add.by()` for lists created with `by()`, allowing such 370 lists to be added to ggplot objects (#2734, @Maschette) 371 372* ggplot2 no longer depends on reshape2, which means that it no longer 373 (recursively) needs plyr, stringr, or stringi packages. 374 375* Increase the default `nbin` of `guide_colourbar()` to place the ticks more 376 precisely (#3508, @yutannihilation). 377 378* `manual_scale()` now matches `values` with the order of `breaks` whenever 379 `values` is an unnamed vector. Previously, unnamed `values` would match with 380 the limits of the scale and ignore the order of any `breaks` provided. Note 381 that this may change the appearance of plots that previously relied on the 382 unordered behaviour (#2429, @idno0001). 383 384* `scale_manual_*(limits = ...)` now actually limits the scale (#3262, 385 @yutannihilation). 386 387* Fix a bug when `show.legend` is a named logical vector 388 (#3461, @yutannihilation). 389 390* Added weight aesthetic option to `stat_density()` and made scaling of 391 weights the default (@annennenne, #2902) 392 393* `stat_density2d()` can now take an `adjust` parameter to scale the default 394 bandwidth. (#2860, @haleyjeppson) 395 396* `stat_smooth()` uses `REML` by default, if `method = "gam"` and 397 `gam`'s method is not specified (@ikosmidis, #2630). 398 399* stacking text when calculating the labels and the y axis with 400 `stat_summary()` now works (@ikosmidis, #2709) 401 402* `stat_summary()` and related functions now support rlang-style lambda functions 403 (#3568, @dkahle). 404 405* The data mask pronoun, `.data`, is now stripped from default labels. 406 407* Addition of partial themes to plots has been made more predictable; 408 stepwise addition of individual partial themes is now equivalent to 409 addition of multple theme elements at once (@clauswilke, #3039). 410 411* Facets now don't fail even when some variable in the spec are not available 412 in all layers (@yutannihilation, #2963). 413 414# ggplot2 3.2.1 415 416This is a patch release fixing a few regressions introduced in 3.2.0 as well as 417fixing some unit tests that broke due to upstream changes. 418 419* `position_stack()` no longer changes the order of the input data. Changes to 420 the internal behaviour of `geom_ribbon()` made this reordering problematic 421 with ribbons that spanned `y = 0` (#3471) 422* Using `qplot()` with a single positional aesthetic will no longer title the 423 non-specified scale as `"NULL"` (#3473) 424* Fixes unit tests for sf graticule labels caused by chages to sf 425 426# ggplot2 3.2.0 427 428This is a minor release with an emphasis on internal changes to make ggplot2 429faster and more consistent. The few interface changes will only affect the 430aesthetics of the plot in minor ways, and will only potentially break code of 431extension developers if they have relied on internals that have been changed. 432This release also sees the addition of Hiroaki Yutani (@yutannihilation) to the 433core developer team. 434 435With the release of R 3.6, ggplot2 now requires the R version to be at least 3.2, 436as the tidyverse is committed to support 5 major versions of R. 437 438## Breaking changes 439 440* Two patches (#2996 and #3050) fixed minor rendering problems. In most cases, 441 the visual changes are so subtle that they are difficult to see with the naked 442 eye. However, these changes are detected by the vdiffr package, and therefore 443 any package developers who use vdiffr to test for visual correctness of ggplot2 444 plots will have to regenerate all reference images. 445 446* In some cases, ggplot2 now produces a warning or an error for code that previously 447 produced plot output. In all these cases, the previous plot output was accidental, 448 and the plotting code uses the ggplot2 API in a way that would lead to undefined 449 behavior. Examples include a missing `group` aesthetic in `geom_boxplot()` (#3316), 450 annotations across multiple facets (#3305), and not using aesthetic mappings when 451 drawing ribbons with `geom_ribbon()` (#3318). 452 453## New features 454 455* This release includes a range of internal changes that speeds up plot 456 generation. None of the changes are user facing and will not break any code, 457 but in general ggplot2 should feel much faster. The changes includes, but are 458 not limited to: 459 460 - Caching ascent and descent dimensions of text to avoid recalculating it for 461 every title. 462 463 - Using a faster data.frame constructor as well as faster indexing into 464 data.frames 465 466 - Removing the plyr dependency, replacing plyr functions with faster 467 equivalents. 468 469* `geom_polygon()` can now draw polygons with holes using the new `subgroup` 470 aesthetic. This functionality requires R 3.6.0 (@thomasp85, #3128) 471 472* Aesthetic mappings now accept functions that return `NULL` (@yutannihilation, 473 #2997). 474 475* `stat_function()` now accepts rlang/purrr style anonymous functions for the 476 `fun` parameter (@dkahle, #3159). 477 478* `geom_rug()` gains an "outside" option to allow for moving the rug tassels to 479 outside the plot area (@njtierney, #3085) and a `length` option to allow for 480 changing the length of the rug lines (@daniel-wells, #3109). 481 482* All geoms now take a `key_glyph` paramter that allows users to customize 483 how legend keys are drawn (@clauswilke, #3145). In addition, a new key glyph 484 `timeseries` is provided to draw nice legends for time series 485 (@mitchelloharawild, #3145). 486 487## Extensions 488 489* Layers now have a new member function `setup_layer()` which is called at the 490 very beginning of the plot building process and which has access to the 491 original input data and the plot object being built. This function allows the 492 creation of custom layers that autogenerate aesthetic mappings based on the 493 input data or that filter the input data in some form. For the time being, this 494 feature is not exported, but it has enabled the development of a new layer type, 495 `layer_sf()` (see next item). Other special-purpose layer types may be added 496 in the future (@clauswilke, #2872). 497 498* A new layer type `layer_sf()` can auto-detect and auto-map sf geometry 499 columns in the data. It should be used by extension developers who are writing 500 new sf-based geoms or stats (@clauswilke, #3232). 501 502* `x0` and `y0` are now recognized positional aesthetics so they will get scaled 503 if used in extension geoms and stats (@thomasp85, #3168) 504 505* Continuous scale limits now accept functions which accept the default 506 limits and return adjusted limits. This makes it possible to write 507 a function that e.g. ensures the limits are always a multiple of 100, 508 regardless of the data (@econandrew, #2307). 509 510## Minor improvements and bug fixes 511 512* `cut_width()` now accepts `...` to pass further arguments to `base::cut.default()` 513 like `cut_number()` and `cut_interval()` already did (@cderv, #3055) 514 515* `coord_map()` now can have axes on the top and right (@karawoo, #3042). 516 517* `coord_polar()` now correctly rescales the secondary axis (@linzi-sg, #3278) 518 519* `coord_sf()`, `coord_map()`, and `coord_polar()` now squash `-Inf` and `Inf` 520 into the min and max of the plot (@yutannihilation, #2972). 521 522* `coord_sf()` graticule lines are now drawn in the same thickness as panel grid 523 lines in `coord_cartesian()`, and seting panel grid lines to `element_blank()` 524 now also works in `coord_sf()` 525 (@clauswilke, #2991, #2525). 526 527* `economics` data has been regenerated. This leads to some changes in the 528 values of all columns (especially in `psavert`), but more importantly, strips 529 the grouping attributes from `economics_long`. 530 531* `element_line()` now fills closed arrows (@yutannihilation, #2924). 532 533* Facet strips on the left side of plots now have clipping turned on, preventing 534 text from running out of the strip and borders from looking thicker than for 535 other strips (@karawoo, #2772 and #3061). 536 537* ggplot2 now works in Turkish locale (@yutannihilation, #3011). 538 539* Clearer error messages for inappropriate aesthetics (@clairemcwhite, #3060). 540 541* ggplot2 no longer attaches any external packages when using functions that 542 depend on packages that are suggested but not imported by ggplot2. The 543 affected functions include `geom_hex()`, `stat_binhex()`, 544 `stat_summary_hex()`, `geom_quantile()`, `stat_quantile()`, and `map_data()` 545 (@clauswilke, #3126). 546 547* `geom_area()` and `geom_ribbon()` now sort the data along the x-axis in the 548 `setup_data()` method rather than as part of `draw_group()` (@thomasp85, 549 #3023) 550 551* `geom_hline()`, `geom_vline()`, and `geom_abline()` now throw a warning if the 552 user supplies both an `xintercept`, `yintercept`, or `slope` value and a 553 mapping (@RichardJActon, #2950). 554 555* `geom_rug()` now works with `coord_flip()` (@has2k1, #2987). 556 557* `geom_violin()` no longer throws an error when quantile lines fall outside 558 the violin polygon (@thomasp85, #3254). 559 560* `guide_legend()` and `guide_colorbar()` now use appropriate spacing between legend 561 key glyphs and legend text even if the legend title is missing (@clauswilke, #2943). 562 563* Default labels are now generated more consistently; e.g., symbols no longer 564 get backticks, and long expressions are abbreviated with `...` 565 (@yutannihilation, #2981). 566 567* All-`Inf` layers are now ignored for picking the scale (@yutannihilation, 568 #3184). 569 570* Diverging Brewer colour palette now use the correct mid-point colour 571 (@dariyasydykova, #3072). 572 573* `scale_color_continuous()` now points to `scale_colour_continuous()` so that 574 it will handle `type = "viridis"` as the documentation states (@hlendway, 575 #3079). 576 577* `scale_shape_identity()` now works correctly with `guide = "legend"` 578 (@malcolmbarrett, #3029) 579 580* `scale_continuous` will now draw axis line even if the length of breaks is 0 581 (@thomasp85, #3257) 582 583* `stat_bin()` will now error when the number of bins exceeds 1e6 to avoid 584 accidentally freezing the user session (@thomasp85). 585 586* `sec_axis()` now places ticks accurately when using nonlinear transformations (@dpseidel, #2978). 587 588* `facet_wrap()` and `facet_grid()` now automatically remove NULL from facet 589 specs, and accept empty specs (@yutannihilation, #3070, #2986). 590 591* `stat_bin()` now handles data with only one unique value (@yutannihilation 592 #3047). 593 594* `sec_axis()` now accepts functions as well as formulas (@yutannihilation, #3031). 595 596* New theme elements allowing different ticks lengths for each axis. For instance, 597 this can be used to have inwards ticks on the x-axis (`axis.ticks.length.x`) and 598 outwards ticks on the y-axis (`axis.ticks.length.y`) (@pank, #2935). 599 600* The arguments of `Stat*$compute_layer()` and `Position*$compute_layer()` are 601 now renamed to always match the ones of `Stat$compute_layer()` and 602 `Position$compute_layer()` (@yutannihilation, #3202). 603 604* `geom_*()` and `stat_*()` now accepts purrr-style lambda notation 605 (@yutannihilation, #3138). 606 607* `geom_tile()` and `geom_rect()` now draw rectangles without notches at the 608 corners. The style of the corner can be controlled by `linejoin` parameters 609 (@yutannihilation, #3050). 610 611# ggplot2 3.1.0 612 613## Breaking changes 614 615This is a minor release and breaking changes have been kept to a minimum. End users of 616ggplot2 are unlikely to encounter any issues. However, there are a few items that developers 617of ggplot2 extensions should be aware of. For additional details, see also the discussion 618accompanying issue #2890. 619 620* In non-user-facing internal code (specifically in the `aes()` function and in 621 the `aesthetics` argument of scale functions), ggplot2 now always uses the British 622 spelling for aesthetics containing the word "colour". When users specify a "color" 623 aesthetic it is automatically renamed to "colour". This renaming is also applied 624 to non-standard aesthetics that contain the word "color". For example, "point_color" 625 is renamed to "point_colour". This convention makes it easier to support both 626 British and American spelling for novel, non-standard aesthetics, but it may require 627 some adjustment for packages that have previously introduced non-standard color 628 aesthetics using American spelling. A new function `standardise_aes_names()` is 629 provided in case extension writers need to perform this renaming in their own code 630 (@clauswilke, #2649). 631 632* Functions that generate other functions (closures) now force the arguments that are 633 used from the generated functions, to avoid hard-to-catch errors. This may affect 634 some users of manual scales (such as `scale_colour_manual()`, `scale_fill_manual()`, 635 etc.) who depend on incorrect behavior (@krlmlr, #2807). 636 637* `Coord` objects now have a function `backtransform_range()` that returns the 638 panel range in data coordinates. This change may affect developers of custom coords, 639 who now should implement this function. It may also affect developers of custom 640 geoms that use the `range()` function. In some applications, `backtransform_range()` 641 may be more appropriate (@clauswilke, #2821). 642 643 644## New features 645 646* `coord_sf()` has much improved customization of axis tick labels. Labels can now 647 be set manually, and there are two new parameters, `label_graticule` and 648 `label_axes`, that can be used to specify which graticules to label on which side 649 of the plot (@clauswilke, #2846, #2857, #2881). 650 651* Two new geoms `geom_sf_label()` and `geom_sf_text()` can draw labels and text 652 on sf objects. Under the hood, a new `stat_sf_coordinates()` calculates the 653 x and y coordinates from the coordinates of the sf geometries. You can customize 654 the calculation method via `fun.geometry` argument (@yutannihilation, #2761). 655 656 657## Minor improvements and fixes 658 659* `benchplot()` now uses tidy evaluation (@dpseidel, #2699). 660 661* The error message in `compute_aesthetics()` now only provides the names of 662 aesthetics with mismatched lengths, rather than all aesthetics (@karawoo, 663 #2853). 664 665* For faceted plots, data is no longer internally reordered. This makes it 666 safer to feed data columns into `aes()` or into parameters of geoms or 667 stats. However, doing so remains discouraged (@clauswilke, #2694). 668 669* `coord_sf()` now also understands the `clip` argument, just like the other 670 coords (@clauswilke, #2938). 671 672* `fortify()` now displays a more informative error message for 673 `grouped_df()` objects when dplyr is not installed (@jimhester, #2822). 674 675* All `geom_*()` now display an informative error message when required 676 aesthetics are missing (@dpseidel, #2637 and #2706). 677 678* `geom_boxplot()` now understands the `width` parameter even when used with 679 a non-standard stat, such as `stat_identity()` (@clauswilke, #2893). 680 681* `geom_hex()` now understands the `size` and `linetype` aesthetics 682 (@mikmart, #2488). 683 684* `geom_hline()`, `geom_vline()`, and `geom_abline()` now work properly 685 with `coord_trans()` (@clauswilke, #2149, #2812). 686 687* `geom_text(..., parse = TRUE)` now correctly renders the expected number of 688 items instead of silently dropping items that are empty expressions, e.g. 689 the empty string "". If an expression spans multiple lines, we take just 690 the first line and drop the rest. This same issue is also fixed for 691 `geom_label()` and the axis labels for `geom_sf()` (@slowkow, #2867). 692 693* `geom_sf()` now respects `lineend`, `linejoin`, and `linemitre` parameters 694 for lines and polygons (@alistaire47, #2826). 695 696* `ggsave()` now exits without creating a new graphics device if previously 697 none was open (@clauswilke, #2363). 698 699* `labs()` now has named arguments `title`, `subtitle`, `caption`, and `tag`. 700 Also, `labs()` now accepts tidyeval (@yutannihilation, #2669). 701 702* `position_nudge()` is now more robust and nudges only in the direction 703 requested. This enables, for example, the horizontal nudging of boxplots 704 (@clauswilke, #2733). 705 706* `sec_axis()` and `dup_axis()` now return appropriate breaks for the secondary 707 axis when applied to log transformed scales (@dpseidel, #2729). 708 709* `sec_axis()` now works as expected when used in combination with tidy eval 710 (@dpseidel, #2788). 711 712* `scale_*_date()`, `scale_*_time()` and `scale_*_datetime()` can now display 713 a secondary axis that is a __one-to-one__ transformation of the primary axis, 714 implemented using the `sec.axis` argument to the scale constructor 715 (@dpseidel, #2244). 716 717* `stat_contour()`, `stat_density2d()`, `stat_bin2d()`, `stat_binhex()` 718 now calculate normalized statistics including `nlevel`, `ndensity`, and 719 `ncount`. Also, `stat_density()` now includes the calculated statistic 720 `nlevel`, an alias for `scaled`, to better match the syntax of `stat_bin()` 721 (@bjreisman, #2679). 722 723# ggplot2 3.0.0 724 725## Breaking changes 726 727* ggplot2 now supports/uses tidy evaluation (as described below). This is a 728 major change and breaks a number of packages; we made this breaking change 729 because it is important to make ggplot2 more programmable, and to be more 730 consistent with the rest of the tidyverse. The best general (and detailed) 731 introduction to tidy evaluation can be found in the meta programming 732 chapters in [Advanced R](https://adv-r.hadley.nz). 733 734 The primary developer facing change is that `aes()` now contains 735 quosures (expression + environment pairs) rather than symbols, and you'll 736 need to take a different approach to extracting the information you need. 737 A common symptom of this change are errors "undefined columns selected" or 738 "invalid 'type' (list) of argument" (#2610). As in the previous version, 739 constants (like `aes(x = 1)` or `aes(colour = "smoothed")`) are stored 740 as is. 741 742 In this version of ggplot2, if you need to describe a mapping in a string, 743 use `quo_name()` (to generate single-line strings; longer expressions may 744 be abbreviated) or `quo_text()` (to generate non-abbreviated strings that 745 may span multiple lines). If you do need to extract the value of a variable 746 instead use `rlang::eval_tidy()`. You may want to condition on 747 `(packageVersion("ggplot2") <= "2.2.1")` so that your code can work with 748 both released and development versions of ggplot2. 749 750 We recognise that this is a big change and if you're not already familiar 751 with rlang, there's a lot to learn. If you are stuck, or need any help, 752 please reach out on <https://community.rstudio.com>. 753 754* Error: Column `y` must be a 1d atomic vector or a list 755 756 Internally, ggplot2 now uses `as.data.frame(tibble::as_tibble(x))` to 757 convert a list into a data frame. This improves ggplot2's support for 758 list-columns (needed for sf support), at a small cost: you can no longer 759 use matrix-columns. Note that unlike tibble we still allow column vectors 760 such as returned by `base::scale()` because of their widespread use. 761 762* Error: More than one expression parsed 763 764 Previously `aes_string(x = c("a", "b", "c"))` silently returned 765 `aes(x = a)`. Now this is a clear error. 766 767* Error: `data` must be uniquely named but has duplicate columns 768 769 If layer data contains columns with identical names an error will be 770 thrown. In earlier versions the first occuring column was chosen silently, 771 potentially masking that the wrong data was chosen. 772 773* Error: Aesthetics must be either length 1 or the same as the data 774 775 Layers are stricter about the columns they will combine into a single 776 data frame. Each aesthetic now must be either the same length as the data 777 frame or a single value. This makes silent recycling errors much less likely. 778 779* Error: `coord_*` doesn't support free scales 780 781 Free scales only work with selected coordinate systems; previously you'd 782 get an incorrect plot. 783 784* Error in f(...) : unused argument (range = c(0, 1)) 785 786 This is because the `oob` argument to scale has been set to a function 787 that only takes a single argument; it needs to take two arguments 788 (`x`, and `range`). 789 790* Error: unused argument (output) 791 792 The function `guide_train()` now has an optional parameter `aesthetic` 793 that allows you to override the `aesthetic` setting in the scale. 794 To make your code work with the both released and development versions of 795 ggplot2 appropriate, add `aesthetic = NULL` to the `guide_train()` method 796 signature. 797 798 ```R 799 # old 800 guide_train.legend <- function(guide, scale) {...} 801 802 # new 803 guide_train.legend <- function(guide, scale, aesthetic = NULL) {...} 804 ``` 805 806 Then, inside the function, replace `scale$aesthetics[1]`, 807 `aesthetic %||% scale$aesthetics[1]`. (The %||% operator is defined in the 808 rlang package). 809 810 ```R 811 # old 812 setNames(list(scale$map(breaks)), scale$aesthetics[1]) 813 814 # new 815 setNames(list(scale$map(breaks)), aesthetic %||% scale$aesthetics[1]) 816 ``` 817 818* The long-deprecated `subset` argument to `layer()` has been removed. 819 820## Tidy evaluation 821 822* `aes()` now supports quasiquotation so that you can use `!!`, `!!!`, 823 and `:=`. This replaces `aes_()` and `aes_string()` which are now 824 soft-deprecated (but will remain around for a long time). 825 826* `facet_wrap()` and `facet_grid()` now support `vars()` inputs. Like 827 `dplyr::vars()`, this helper quotes its inputs and supports 828 quasiquotation. For instance, you can now supply faceting variables 829 like this: `facet_wrap(vars(am, cyl))` instead of 830 `facet_wrap(~am + cyl)`. Note that the formula interface is not going 831 away and will not be deprecated. `vars()` is simply meant to make it 832 easier to create functions around `facet_wrap()` and `facet_grid()`. 833 834 The first two arguments of `facet_grid()` become `rows` and `cols` 835 and now support `vars()` inputs. Note however that we took special 836 care to ensure complete backward compatibility. With this change 837 `facet_grid(vars(cyl), vars(am, vs))` is equivalent to 838 `facet_grid(cyl ~ am + vs)`, and `facet_grid(cols = vars(am, vs))` is 839 equivalent to `facet_grid(. ~ am + vs)`. 840 841 One nice aspect of the new interface is that you can now easily 842 supply names: `facet_grid(vars(Cylinder = cyl), labeller = 843 label_both)` will give nice label titles to the facets. Of course, 844 those names can be unquoted with the usual tidy eval syntax. 845 846### sf 847 848* ggplot2 now has full support for sf with `geom_sf()` and `coord_sf()`: 849 850 ```r 851 nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) 852 ggplot(nc) + 853 geom_sf(aes(fill = AREA)) 854 ``` 855 It supports all simple features, automatically aligns CRS across layers, sets 856 up the correct aspect ratio, and draws a graticule. 857 858## New features 859 860* ggplot2 now works on R 3.1 onwards, and uses the 861 [vdiffr](https://github.com/r-lib/vdiffr) package for visual testing. 862 863* In most cases, accidentally using `%>%` instead of `+` will generate an 864 informative error (#2400). 865 866* New syntax for calculated aesthetics. Instead of using `aes(y = ..count..)` 867 you can (and should!) use `aes(y = stat(count))`. `stat()` is a real function 868 with documentation which hopefully will make this part of ggplot2 less 869 confusing (#2059). 870 871 `stat()` is particularly nice for more complex calculations because you 872 only need to specify it once: `aes(y = stat(count / max(count)))`, 873 rather than `aes(y = ..count.. / max(..count..))` 874 875* New `tag` label for adding identification tags to plots, typically used for 876 labelling a subplot with a letter. Add a tag with `labs(tag = "A")`, style it 877 with the `plot.tag` theme element, and control position with the 878 `plot.tag.position` theme setting (@thomasp85). 879 880### Layers: geoms, stats, and position adjustments 881 882* `geom_segment()` and `geom_curve()` have a new `arrow.fill` parameter which 883 allows you to specify a separate fill colour for closed arrowheads 884 (@hrbrmstr and @clauswilke, #2375). 885 886* `geom_point()` and friends can now take shapes as strings instead of integers, 887 e.g. `geom_point(shape = "diamond")` (@daniel-barnett, #2075). 888 889* `position_dodge()` gains a `preserve` argument that allows you to control 890 whether the `total` width at each `x` value is preserved (the current 891 default), or ensure that the width of a `single` element is preserved 892 (what many people want) (#1935). 893 894* New `position_dodge2()` provides enhanced dodging for boxplots. Compared to 895 `position_dodge()`, `position_dodge2()` compares `xmin` and `xmax` values 896 to determine which elements overlap, and spreads overlapping elements evenly 897 within the region of overlap. `position_dodge2()` is now the default position 898 adjustment for `geom_boxplot()`, because it handles `varwidth = TRUE`, and 899 will be considered for other geoms in the future. 900 901 The `padding` parameter adds a small amount of padding between elements 902 (@karawoo, #2143) and a `reverse` parameter allows you to reverse the order 903 of placement (@karawoo, #2171). 904 905* New `stat_qq_line()` makes it easy to add a simple line to a Q-Q plot, which 906 makes it easier to judge the fit of the theoretical distribution 907 (@nicksolomon). 908 909### Scales and guides 910 911* Improved support for mapping date/time variables to `alpha`, `size`, `colour`, 912 and `fill` aesthetics, including `date_breaks` and `date_labels` arguments 913 (@karawoo, #1526), and new `scale_alpha()` variants (@karawoo, #1526). 914 915* Improved support for ordered factors. Ordered factors throw a warning when 916 mapped to shape (unordered factors do not), and do not throw warnings when 917 mapped to size or alpha (unordered factors do). Viridis is used as the 918 default colour and fill scale for ordered factors (@karawoo, #1526). 919 920* The `expand` argument of `scale_*_continuous()` and `scale_*_discrete()` 921 now accepts separate expansion values for the lower and upper range 922 limits. The expansion limits can be specified using the convenience 923 function `expand_scale()`. 924 925 Separate expansion limits may be useful for bar charts, e.g. if one 926 wants the bottom of the bars to be flush with the x axis but still 927 leave some (automatically calculated amount of) space above them: 928 929 ```r 930 ggplot(mtcars) + 931 geom_bar(aes(x = factor(cyl))) + 932 scale_y_continuous(expand = expand_scale(mult = c(0, .1))) 933 ``` 934 935 It can also be useful for line charts, e.g. for counts over time, 936 where one wants to have a ’hard’ lower limit of y = 0 but leave the 937 upper limit unspecified (and perhaps differing between panels), with 938 some extra space above the highest point on the line (with symmetrical 939 limits, the extra space above the highest point could in some cases 940 cause the lower limit to be negative). 941 942 The old syntax for the `expand` argument will, of course, continue 943 to work (@huftis, #1669). 944 945* `scale_colour_continuous()` and `scale_colour_gradient()` are now controlled 946 by global options `ggplot2.continuous.colour` and `ggplot2.continuous.fill`. 947 These can be set to `"gradient"` (the default) or `"viridis"` (@karawoo). 948 949* New `scale_colour_viridis_c()`/`scale_fill_viridis_c()` (continuous) and 950 `scale_colour_viridis_d()`/`scale_fill_viridis_d()` (discrete) make it 951 easy to use Viridis colour scales (@karawoo, #1526). 952 953* Guides for `geom_text()` now accept custom labels with 954 `guide_legend(override.aes = list(label = "foo"))` (@brianwdavis, #2458). 955 956### Margins 957 958* Strips gain margins on all sides by default. This means that to fully justify 959 text to the edge of a strip, you will need to also set the margins to 0 960 (@karawoo). 961 962* Rotated strip labels now correctly understand `hjust` and `vjust` parameters 963 at all angles (@karawoo). 964 965* Strip labels now understand justification relative to the direction of the 966 text, meaning that in y facets, the strip text can be placed at either end of 967 the strip using `hjust` (@karawoo). 968 969* Legend titles and labels get a little extra space around them, which 970 prevents legend titles from overlapping the legend at large font sizes 971 (@karawoo, #1881). 972 973## Extension points 974 975* New `autolayer()` S3 generic (@mitchelloharawild, #1974). This is similar 976 to `autoplot()` but produces layers rather than complete plots. 977 978* Custom objects can now be added using `+` if a `ggplot_add` method has been 979 defined for the class of the object (@thomasp85). 980 981* Theme elements can now be subclassed. Add a `merge_element` method to control 982 how properties are inherited from the parent element. Add an `element_grob` 983 method to define how elements are rendered into grobs (@thomasp85, #1981). 984 985* Coords have gained new extension mechanisms. 986 987 If you have an existing coord extension, you will need to revise the 988 specification of the `train()` method. It is now called 989 `setup_panel_params()` (better reflecting what it actually does) and now 990 has arguments `scale_x`, and `scale_y` (the x and y scales respectively) 991 and `param`, a list of plot specific parameters generated by 992 `setup_params()`. 993 994 What was formerly called `scale_details` (in coords), `panel_ranges` 995 (in layout) and `panel_scales` (in geoms) are now consistently called 996 `panel_params` (#1311). These are parameters of the coord that vary from 997 panel to panel. 998 999* `ggplot_build()` and `ggplot_gtable()` are now generics, so ggplot-subclasses 1000 can define additional behavior during the build stage. 1001 1002* `guide_train()`, `guide_merge()`, `guide_geom()`, and `guide_gengrob()` 1003 are now exported as they are needed if you want to design your own guide. 1004 They are not currently documented; use at your own risk (#2528). 1005 1006* `scale_type()` generic is now exported and documented. Use this if you 1007 want to extend ggplot2 to work with a new type of vector. 1008 1009## Minor bug fixes and improvements 1010 1011### Faceting 1012 1013* `facet_grid()` gives a more informative error message if you try to use 1014 a variable in both rows and cols (#1928). 1015 1016* `facet_grid()` and `facet_wrap()` both give better error messages if you 1017 attempt to use an unsupported coord with free scales (#2049). 1018 1019* `label_parsed()` works once again (#2279). 1020 1021* You can now style the background of horizontal and vertical strips 1022 independently with `strip.background.x` and `strip.background.y` 1023 theme settings (#2249). 1024 1025### Scales 1026 1027* `discrete_scale()` documentation now inherits shared definitions from 1028 `continuous_scale()` (@alistaire47, #2052). 1029 1030* `guide_colorbar()` shows all colours of the scale (@has2k1, #2343). 1031 1032* `scale_identity()` once again produces legends by default (#2112). 1033 1034* Tick marks for secondary axes with strong transformations are more 1035 accurately placed (@thomasp85, #1992). 1036 1037* Missing line types now reliably generate missing lines (with standard 1038 warning) (#2206). 1039 1040* Legends now ignore set aesthetics that are not length one (#1932). 1041 1042* All colour and fill scales now have an `aesthetics` argument that can 1043 be used to set the aesthetic(s) the scale works with. This makes it 1044 possible to apply a colour scale to both colour and fill aesthetics 1045 at the same time, via `aesthetics = c("colour", "fill")` (@clauswilke). 1046 1047* Three new generic scales work with any aesthetic or set of aesthetics: 1048 `scale_continuous_identity()`, `scale_discrete_identity()`, and 1049 `scale_discrete_manual()` (@clauswilke). 1050 1051* `scale_*_gradient2()` now consistently omits points outside limits by 1052 rescaling after the limits are enforced (@foo-bar-baz-qux, #2230). 1053 1054### Layers 1055 1056* `geom_label()` now correctly produces unbordered labels when `label.size` 1057 is 0, even when saving to PDF (@bfgray3, #2407). 1058 1059* `layer()` gives considerably better error messages for incorrectly specified 1060 `geom`, `stat`, or `position` (#2401). 1061 1062* In all layers that use it, `linemitre` now defaults to 10 (instead of 1) 1063 to better match base R. 1064 1065* `geom_boxplot()` now supplies a default value if no `x` aesthetic is present 1066 (@foo-bar-baz-qux, #2110). 1067 1068* `geom_density()` drops groups with fewer than two data points and throws a 1069 warning. For groups with two data points, density values are now calculated 1070 with `stats::density` (@karawoo, #2127). 1071 1072* `geom_segment()` now also takes a `linejoin` parameter. This allows more 1073 control over the appearance of the segments, which is especially useful for 1074 plotting thick arrows (@Ax3man, #774). 1075 1076* `geom_smooth()` now reports the formula used when `method = "auto"` 1077 (@davharris #1951). `geom_smooth()` now orders by the `x` aesthetic, making it 1078 easier to pass pre-computed values without manual ordering (@izahn, #2028). It 1079 also now knows it has `ymin` and `ymax` aesthetics (#1939). The legend 1080 correctly reflects the status of the `se` argument when used with stats 1081 other than the default (@clauswilke, #1546). 1082 1083* `geom_tile()` now once again interprets `width` and `height` correctly 1084 (@malcolmbarrett, #2510). 1085 1086* `position_jitter()` and `position_jitterdodge()` gain a `seed` argument that 1087 allows the specification of a random seed for reproducible jittering 1088 (@krlmlr, #1996 and @slowkow, #2445). 1089 1090* `stat_density()` has better behaviour if all groups are dropped because they 1091 are too small (#2282). 1092 1093* `stat_summary_bin()` now understands the `breaks` parameter (@karawoo, #2214). 1094 1095* `stat_bin()` now accepts functions for `binwidth`. This allows better binning 1096 when faceting along variables with different ranges (@botanize). 1097 1098* `stat_bin()` and `geom_histogram()` now sum correctly when using the `weight` 1099 aesthetic (@jiho, #1921). 1100 1101* `stat_bin()` again uses correct scaling for the computed variable `ndensity` 1102 (@timgoodman, #2324). 1103 1104* `stat_bin()` and `stat_bin_2d()` now properly handle the `breaks` parameter 1105 when the scales are transformed (@has2k1, #2366). 1106 1107* `update_geom_defaults()` and `update_stat_defaults()` allow American 1108 spelling of aesthetic parameters (@foo-bar-baz-qux, #2299). 1109 1110* The `show.legend` parameter now accepts a named logical vector to hide/show 1111 only some aesthetics in the legend (@tutuchan, #1798). 1112 1113* Layers now silently ignore unknown aesthetics with value `NULL` (#1909). 1114 1115### Coords 1116 1117* Clipping to the plot panel is now configurable, through a `clip` argument 1118 to coordinate systems, e.g. `coord_cartesian(clip = "off")` 1119 (@clauswilke, #2536). 1120 1121* Like scales, coordinate systems now give you a message when you're 1122 replacing an existing coordinate system (#2264). 1123 1124* `coord_polar()` now draws secondary axis ticks and labels 1125 (@dylan-stark, #2072), and can draw the radius axis on the right 1126 (@thomasp85, #2005). 1127 1128* `coord_trans()` now generates a warning when a transformation generates 1129 non-finite values (@foo-bar-baz-qux, #2147). 1130 1131### Themes 1132 1133* Complete themes now always override all elements of the default theme 1134 (@has2k1, #2058, #2079). 1135 1136* Themes now set default grid colour in `panel.grid` rather than individually 1137 in `panel.grid.major` and `panel.grid.minor` individually. This makes it 1138 slightly easier to customise the theme (#2352). 1139 1140* Fixed bug when setting strips to `element_blank()` (@thomasp85). 1141 1142* Axes positioned on the top and to the right can now customize their ticks and 1143 lines separately (@thomasp85, #1899). 1144 1145* Built-in themes gain parameters `base_line_size` and `base_rect_size` which 1146 control the default sizes of line and rectangle elements (@karawoo, #2176). 1147 1148* Default themes use `rel()` to set line widths (@baptiste). 1149 1150* Themes were tweaked for visual consistency and more graceful behavior when 1151 changing the base font size. All absolute heights or widths were replaced 1152 with heights or widths that are proportional to the base font size. One 1153 relative font size was eliminated (@clauswilke). 1154 1155* The height of descenders is now calculated solely on font metrics and doesn't 1156 change with the specific letters in the string. This fixes minor alignment 1157 issues with plot titles, subtitles, and legend titles (#2288, @clauswilke). 1158 1159### Guides 1160 1161* `guide_colorbar()` is more configurable: tick marks and color bar frame 1162 can now by styled with arguments `ticks.colour`, `ticks.linewidth`, 1163 `frame.colour`, `frame.linewidth`, and `frame.linetype` 1164 (@clauswilke). 1165 1166* `guide_colorbar()` now uses `legend.spacing.x` and `legend.spacing.y` 1167 correctly, and it can handle multi-line titles. Minor tweaks were made to 1168 `guide_legend()` to make sure the two legend functions behave as similarly as 1169 possible (@clauswilke, #2397 and #2398). 1170 1171* The theme elements `legend.title` and `legend.text` now respect the settings 1172 of `margin`, `hjust`, and `vjust` (@clauswilke, #2465, #1502). 1173 1174* Non-angle parameters of `label.theme` or `title.theme` can now be set in 1175 `guide_legend()` and `guide_colorbar()` (@clauswilke, #2544). 1176 1177### Other 1178 1179* `fortify()` gains a method for tbls (@karawoo, #2218). 1180 1181* `ggplot` gains a method for `grouped_df`s that adds a `.group` variable, 1182 which computes a unique value for each group. Use it with 1183 `aes(group = .group)` (#2351). 1184 1185* `ggproto()` produces objects with class `c("ggproto", "gg")`, allowing for 1186 a more informative error message when adding layers, scales, or other ggproto 1187 objects (@jrnold, #2056). 1188 1189* `ggsave()`'s DPI argument now supports 3 string options: "retina" (320 1190 DPI), "print" (300 DPI), and "screen" (72 DPI) (@foo-bar-baz-qux, #2156). 1191 `ggsave()` now uses full argument names to avoid partial match warnings 1192 (#2355), and correctly restores the previous graphics device when several 1193 graphics devices are open (#2363). 1194 1195* `print.ggplot()` now returns the original ggplot object, instead of the 1196 output from `ggplot_build()`. Also, the object returned from 1197 `ggplot_build()` now has the class `"ggplot_built"` (#2034). 1198 1199* `map_data()` now works even when purrr is loaded (tidyverse#66). 1200 1201* New functions `summarise_layout()`, `summarise_coord()`, and 1202 `summarise_layers()` summarise the layout, coordinate systems, and layers 1203 of a built ggplot object (#2034, @wch). This provides a tested API that 1204 (e.g.) shiny can depend on. 1205 1206* Updated startup messages reflect new resources (#2410, @mine-cetinkaya-rundel). 1207 1208# ggplot2 2.2.1 1209 1210* Fix usage of `structure(NULL)` for R-devel compatibility (#1968). 1211 1212# ggplot2 2.2.0 1213 1214## Major new features 1215 1216### Subtitle and caption 1217 1218Thanks to @hrbrmstr plots now have subtitles and captions, which can be set with 1219the `subtitle` and `caption` arguments to `ggtitle()` and `labs()`. You can 1220control their appearance with the theme settings `plot.caption` and 1221`plot.subtitle`. The main plot title is now left-aligned to better work better 1222with a subtitle. The caption is right-aligned (@hrbrmstr). 1223 1224### Stacking 1225 1226`position_stack()` and `position_fill()` now sort the stacking order to match 1227grouping order. This allows you to control the order through grouping, and 1228ensures that the default legend matches the plot (#1552, #1593). If you want the 1229opposite order (useful if you have horizontal bars and horizontal legend), you 1230can request reverse stacking by using `position = position_stack(reverse = TRUE)` 1231(#1837). 1232 1233`position_stack()` and `position_fill()` now accepts negative values which will 1234create stacks extending below the x-axis (#1691). 1235 1236`position_stack()` and `position_fill()` gain a `vjust` argument which makes it 1237easy to (e.g.) display labels in the middle of stacked bars (#1821). 1238 1239### Layers 1240 1241`geom_col()` was added to complement `geom_bar()` (@hrbrmstr). It uses 1242`stat="identity"` by default, making the `y` aesthetic mandatory. It does not 1243support any other `stat_()` and does not provide fallback support for the 1244`binwidth` parameter. Examples and references in other functions were updated to 1245demonstrate `geom_col()` usage. 1246 1247When creating a layer, ggplot2 will warn if you use an unknown aesthetic or an 1248unknown parameter. Compared to the previous version, this is stricter for 1249aesthetics (previously there was no message), and less strict for parameters 1250(previously this threw an error) (#1585). 1251 1252### Facetting 1253 1254The facet system, as well as the internal panel class, has been rewritten in 1255ggproto. Facets are now extendable in the same manner as geoms and stats, as 1256described in `vignette("extending-ggplot2")`. 1257 1258We have also added the following new fatures. 1259 1260* `facet_grid()` and `facet_wrap()` now allow expressions in their faceting 1261 formulas (@DanRuderman, #1596). 1262 1263* When `facet_wrap()` results in an uneven number of panels, axes will now be 1264 drawn underneath the hanging panels (fixes #1607) 1265 1266* Strips can now be freely positioned in `facet_wrap()` using the 1267 `strip.position` argument (deprecates `switch`). 1268 1269* The relative order of panel, strip, and axis can now be controlled with 1270 the theme setting `strip.placement` that takes either `inside` (strip between 1271 panel and axis) or `outside` (strip after axis). 1272 1273* The theme option `panel.margin` has been deprecated in favour of 1274 `panel.spacing` to more clearly communicate intent. 1275 1276### Extensions 1277 1278Unfortunately there was a major oversight in the construction of ggproto which 1279lead to extensions capturing the super object at package build time, instead of 1280at package run time (#1826). This problem has been fixed, but requires 1281re-installation of all extension packages. 1282 1283## Scales 1284 1285* The position of x and y axes can now be changed using the `position` argument 1286 in `scale_x_*`and `scale_y_*` which can take `top` and `bottom`, and `left` 1287 and `right` respectively. The themes of top and right axes can be modified 1288 using the `.top` and `.right` modifiers to `axis.text.*` and `axis.title.*`. 1289 1290### Continuous scales 1291 1292* `scale_x_continuous()` and `scale_y_continuous()` can now display a secondary 1293 axis that is a __one-to-one__ transformation of the primary axis (e.g. degrees 1294 Celcius to degrees Fahrenheit). The secondary axis will be positioned opposite 1295 to the primary axis and can be controlled with the `sec.axis` argument to 1296 the scale constructor. 1297 1298* Scales worry less about having breaks. If no breaks can be computed, the 1299 plot will work instead of throwing an uninformative error (#791). This 1300 is particularly helpful when you have facets with free scales, and not 1301 all panels contain data. 1302 1303* Scales now warn when transformation introduces infinite values (#1696). 1304 1305### Date time 1306 1307* `scale_*_datetime()` now supports time zones. It will use the timezone 1308 attached to the varaible by default, but can be overridden with the 1309 `timezone` argument. 1310 1311* New `scale_x_time()` and `scale_y_time()` generate reasonable default 1312 breaks and labels for hms vectors (#1752). 1313 1314### Discrete scales 1315 1316The treatment of missing values by discrete scales has been thoroughly 1317overhauled (#1584). The underlying principle is that we can naturally represent 1318missing values on discrete variables (by treating just like another level), so 1319by default we should. 1320 1321This principle applies to: 1322 1323* character vectors 1324* factors with implicit NA 1325* factors with explicit NA 1326 1327And to all scales (both position and non-position.) 1328 1329Compared to the previous version of ggplot2, there are three main changes: 1330 13311. `scale_x_discrete()` and `scale_y_discrete()` always show discrete NA, 1332 regardless of their source 1333 13341. If present, `NA`s are shown in discete legends. 1335 13361. All discrete scales gain a `na.translate` argument that allows you to 1337 control whether `NA`s are translated to something that can be visualised, 1338 or should be left as missing. Note that if you don't translate (i.e. 1339 `na.translate = FALSE)` the missing values will passed on to the layer, 1340 which will warning that it's dropping missing values. To suppress the 1341 warnings, you'll also need to add `na.rm = TRUE` to the layer call. 1342 1343There were also a number of other smaller changes 1344 1345* Correctly use scale expansion factors. 1346* Don't preserve space for dropped levels (#1638). 1347* Only issue one warning when when asking for too many levels (#1674). 1348* Unicode labels work better on Windows (#1827). 1349* Warn when used with only continuous data (#1589) 1350 1351## Themes 1352 1353* The `theme()` constructor now has named arguments rather than ellipses. This 1354 should make autocomplete substantially more useful. The documentation 1355 (including examples) has been considerably improved. 1356 1357* Built-in themes are more visually homogeneous, and match `theme_grey` better. 1358 (@jiho, #1679) 1359 1360* When computing the height of titles, ggplot2 now includes the height of the 1361 descenders (i.e. the bits of `g` and `y` that hang beneath the baseline). This 1362 improves the margins around titles, particularly the y axis label (#1712). 1363 I have also very slightly increased the inner margins of axis titles, and 1364 removed the outer margins. 1365 1366* Theme element inheritance is now easier to work with as modification now 1367 overrides default `element_blank` elements (#1555, #1557, #1565, #1567) 1368 1369* Horizontal legends (i.e. legends on the top or bottom) are horizontally 1370 aligned by default (#1842). Use `legend.box = "vertical"` to switch back 1371 to the previous behaviour. 1372 1373* `element_line()` now takes an `arrow` argument to specify arrows at the end of 1374 lines (#1740) 1375 1376There were a number of tweaks to the theme elements that control legends: 1377 1378* `legend.justification` now controls appearance will plotting the legend 1379 outside of the plot area. For example, you can use 1380 `theme(legend.justification = "top")` to make the legend align with the 1381 top of the plot. 1382 1383* `panel.margin` and `legend.margin` have been renamed to `panel.spacing` and 1384 `legend.spacing` respectively, to better communicate intent (they only 1385 affect spacing between legends and panels, not the margins around them) 1386 1387* `legend.margin` now controls margin around individual legends. 1388 1389* New `legend.box.background`, `legend.box.spacing`, and `legend.box.margin` 1390 control the background, spacing, and margin of the legend box (the region 1391 that contains all legends). 1392 1393## Bug fixes and minor improvements 1394 1395* ggplot2 now imports tibble. This ensures that all built-in datasets print 1396 compactly even if you haven't explicitly loaded tibble or dplyr (#1677). 1397 1398* Class of aesthetic mapping is preserved when adding `aes()` objects (#1624). 1399 1400* `+.gg` now works for lists that include data frames. 1401 1402* `annotation_x()` now works in the absense of global data (#1655) 1403 1404* `geom_*(show.legend = FALSE)` now works for `guide_colorbar`. 1405 1406* `geom_boxplot()` gains new `outlier.alpha` (@jonathan-g) and 1407 `outlier.fill` (@schloerke, #1787) parameters to control the alpha/fill of 1408 outlier points independently of the alpha of the boxes. 1409 1410* `position_jitter()` (and hence `geom_jitter()`) now correctly computes 1411 the jitter width/jitter when supplied by the user (#1775, @has2k1). 1412 1413* `geom_contour()` more clearly describes what inputs it needs (#1577). 1414 1415* `geom_curve()` respects the `lineend` paramater (#1852). 1416 1417* `geom_histogram()` and `stat_bin()` understand the `breaks` parameter once 1418 more. (#1665). The floating point adjustment for histogram bins is now 1419 actually used - it was previously inadvertently ignored (#1651). 1420 1421* `geom_violin()` no longer transforms quantile lines with the alpha aesthetic 1422 (@mnbram, #1714). It no longer errors when quantiles are requested but data 1423 have zero range (#1687). When `trim = FALSE` it once again has a nice 1424 range that allows the density to reach zero (by extending the range 3 1425 bandwidths to either side of the data) (#1700). 1426 1427* `geom_dotplot()` works better when faceting and binning on the y-axis. 1428 (#1618, @has2k1). 1429 1430* `geom_hexbin()` once again supports `..density..` (@mikebirdgeneau, #1688). 1431 1432* `geom_step()` gives useful warning if only one data point in layer (#1645). 1433 1434* `layer()` gains new `check.aes` and `check.param` arguments. These allow 1435 geom/stat authors to optional suppress checks for known aesthetics/parameters. 1436 Currently this is used only in `geom_blank()` which powers `expand_limits()` 1437 (#1795). 1438 1439* All `stat_*()` display a better error message when required aesthetics are 1440 missing. 1441 1442* `stat_bin()` and `stat_summary_hex()` now accept length 1 `binwidth` (#1610) 1443 1444* `stat_density()` gains new argument `n`, which is passed to underlying function 1445 `stats::density` ("number of equally spaced points at which the 1446 density is to be estimated"). (@hbuschme) 1447 1448* `stat_binhex()` now again returns `count` rather than `value` (#1747) 1449 1450* `stat_ecdf()` respects `pad` argument (#1646). 1451 1452* `stat_smooth()` once again informs you about the method it has chosen. 1453 It also correctly calculates the size of the largest group within facets. 1454 1455* `x` and `y` scales are now symmetric regarding the list of 1456 aesthetics they accept: `xmin_final`, `xmax_final`, `xlower`, 1457 `xmiddle` and `xupper` are now valid `x` aesthetics. 1458 1459* `Scale` extensions can now override the `make_title` and `make_sec_title` 1460 methods to let the scale modify the axis/legend titles. 1461 1462* The random stream is now reset after calling `.onAttach()` (#2409). 1463 1464# ggplot2 2.1.0 1465 1466## New features 1467 1468* When mapping an aesthetic to a constant (e.g. 1469 `geom_smooth(aes(colour = "loess")))`), the default guide title is the name 1470 of the aesthetic (i.e. "colour"), not the value (i.e. "loess") (#1431). 1471 1472* `layer()` now accepts a function as the data argument. The function will be 1473 applied to the data passed to the `ggplot()` function and must return a 1474 data.frame (#1527, @thomasp85). This is a more general version of the 1475 deprecated `subset` argument. 1476 1477* `theme_update()` now uses the `+` operator instead of `%+replace%`, so that 1478 unspecified values will no longer be `NULL`ed out. `theme_replace()` 1479 preserves the old behaviour if desired (@oneillkza, #1519). 1480 1481* `stat_bin()` has been overhauled to use the same algorithm as ggvis, which 1482 has been considerably improved thanks to the advice of Randy Prium (@rpruim). 1483 This includes: 1484 1485 * Better arguments and a better algorithm for determining the origin. 1486 You can now specify either `boundary` or the `center` of a bin. 1487 `origin` has been deprecated in favour of these arguments. 1488 1489 * `drop` is deprecated in favour of `pad`, which adds extra 0-count bins 1490 at either end (needed for frequency polygons). `geom_histogram()` defaults 1491 to `pad = FALSE` which considerably improves the default limits for 1492 the histogram, especially when the bins are big (#1477). 1493 1494 * The default algorithm does a (somewhat) better job at picking nice widths 1495 and origins across a wider range of input data. 1496 1497 * `bins = n` now gives a histogram with `n` bins, not `n + 1` (#1487). 1498 1499## Bug fixes 1500 1501* All `\donttest{}` examples run. 1502 1503* All `geom_()` and `stat_()` functions now have consistent argument order: 1504 data + mapping, then geom/stat/position, then `...`, then specific arguments, 1505 then arguments common to all layers (#1305). This may break code if you were 1506 previously relying on partial name matching, but in the long-term should make 1507 ggplot2 easier to use. In particular, you can now set the `n` parameter 1508 in `geom_density2d()` without it partially matching `na.rm` (#1485). 1509 1510* For geoms with both `colour` and `fill`, `alpha` once again only affects 1511 fill (Reverts #1371, #1523). This was causing problems for people. 1512 1513* `facet_wrap()`/`facet_grid()` works with multiple empty panels of data 1514 (#1445). 1515 1516* `facet_wrap()` correctly swaps `nrow` and `ncol` when faceting vertically 1517 (#1417). 1518 1519* `ggsave("x.svg")` now uses svglite to produce the svg (#1432). 1520 1521* `geom_boxplot()` now understands `outlier.color` (#1455). 1522 1523* `geom_path()` knows that "solid" (not just 1) represents a solid line (#1534). 1524 1525* `geom_ribbon()` preserves missing values so they correctly generate a 1526 gap in the ribbon (#1549). 1527 1528* `geom_tile()` once again accepts `width` and `height` parameters (#1513). 1529 It uses `draw_key_polygon()` for better a legend, including a coloured 1530 outline (#1484). 1531 1532* `layer()` now automatically adds a `na.rm` parameter if none is explicitly 1533 supplied. 1534 1535* `position_jitterdodge()` now works on all possible dodge aesthetics, 1536 e.g. `color`, `linetype` etc. instead of only based on `fill` (@bleutner) 1537 1538* `position = "nudge"` now works (although it doesn't do anything useful) 1539 (#1428). 1540 1541* The default scale for columns of class "AsIs" is now "identity" (#1518). 1542 1543* `scale_*_discrete()` has better defaults when used with purely continuous 1544 data (#1542). 1545 1546* `scale_size()` warns when used with categorical data. 1547 1548* `scale_size()`, `scale_colour()`, and `scale_fill()` gain date and date-time 1549 variants (#1526). 1550 1551* `stat_bin_hex()` and `stat_bin_summary()` now use the same underlying 1552 algorithm so results are consistent (#1383). `stat_bin_hex()` now accepts 1553 a `weight` aesthetic. To be consistent with related stats, the output variable 1554 from `stat_bin_hex()` is now value instead of count. 1555 1556* `stat_density()` gains a `bw` parameter which makes it easy to get consistent 1557 smoothing between facets (@jiho) 1558 1559* `stat-density-2d()` no longer ignores the `h` parameter, and now accepts 1560 `bins` and `binwidth` parameters to control the number of contours 1561 (#1448, @has2k1). 1562 1563* `stat_ecdf()` does a better job of adding padding to -Inf/Inf, and gains 1564 an argument `pad` to suppress the padding if not needed (#1467). 1565 1566* `stat_function()` gains an `xlim` parameter (#1528). It once again works 1567 with discrete x values (#1509). 1568 1569* `stat_summary()` preserves sorted x order which avoids artefacts when 1570 display results with `geom_smooth()` (#1520). 1571 1572* All elements should now inherit correctly for all themes except `theme_void()`. 1573 (@Katiedaisey, #1555) 1574 1575* `theme_void()` was completely void of text but facets and legends still 1576 need labels. They are now visible (@jiho). 1577 1578* You can once again set legend key and height width to unit arithmetic 1579 objects (like `2 * unit(1, "cm")`) (#1437). 1580 1581* Eliminate spurious warning if you have a layer with no data and no aesthetics 1582 (#1451). 1583 1584* Removed a superfluous comma in `theme-defaults.r` code (@jschoeley) 1585 1586* Fixed a compatibility issue with `ggproto` and R versions prior to 3.1.2. 1587 (#1444) 1588 1589* Fixed issue where `coord_map()` fails when given an explicit `parameters` 1590 argument (@tdmcarthur, #1729) 1591 1592* Fixed issue where `geom_errorbarh()` had a required `x` aesthetic (#1933) 1593 1594# ggplot2 2.0.0 1595 1596## Major changes 1597 1598* ggplot no longer throws an error if your plot has no layers. Instead it 1599 automatically adds `geom_blank()` (#1246). 1600 1601* New `cut_width()` is a convenient replacement for the verbose 1602 `plyr::round_any()`, with the additional benefit of offering finer 1603 control. 1604 1605* New `geom_count()` is a convenient alias to `stat_sum()`. Use it when you 1606 have overlapping points on a scatterplot. `stat_sum()` now defaults to 1607 using counts instead of proportions. 1608 1609* New `geom_curve()` adds curved lines, with a similar specification to 1610 `geom_segment()` (@veraanadi, #1088). 1611 1612* Date and datetime scales now have `date_breaks`, `date_minor_breaks` and 1613 `date_labels` arguments so that you never need to use the long 1614 `scales::date_breaks()` or `scales::date_format()`. 1615 1616* `geom_bar()` now has it's own stat, distinct from `stat_bin()` which was 1617 also used by `geom_histogram()`. `geom_bar()` now uses `stat_count()` 1618 which counts values at each distinct value of x (i.e. it does not bin 1619 the data first). This can be useful when you want to show exactly which 1620 values are used in a continuous variable. 1621 1622* `geom_point()` gains a `stroke` aesthetic which controls the border width of 1623 shapes 21-25 (#1133, @SeySayux). `size` and `stroke` are additive so a point 1624 with `size = 5` and `stroke = 5` will have a diameter of 10mm. (#1142) 1625 1626* New `position_nudge()` allows you to slightly offset labels (or other 1627 geoms) from their corresponding points (#1109). 1628 1629* `scale_size()` now maps values to _area_, not radius. Use `scale_radius()` 1630 if you want the old behaviour (not recommended, except perhaps for lines). 1631 1632* New `stat_summary_bin()` works like `stat_summary()` but on binned data. 1633 It's a generalisation of `stat_bin()` that can compute any aggregate, 1634 not just counts (#1274). Both default to `mean_se()` if no aggregation 1635 functions are supplied (#1386). 1636 1637* Layers are now much stricter about their arguments - you will get an error 1638 if you've supplied an argument that isn't an aesthetic or a parameter. 1639 This is likely to cause some short-term pain but in the long-term it will make 1640 it much easier to spot spelling mistakes and other errors (#1293). 1641 1642 This change does break a handful of geoms/stats that used `...` to pass 1643 additional arguments on to the underlying computation. Now 1644 `geom_smooth()`/`stat_smooth()` and `geom_quantile()`/`stat_quantile()` 1645 use `method.args` instead (#1245, #1289); and `stat_summary()` (#1242), 1646 `stat_summary_hex()`, and `stat_summary2d()` use `fun.args`. 1647 1648### Extensibility 1649 1650There is now an official mechanism for defining Stats, Geoms, and Positions in 1651other packages. See `vignette("extending-ggplot2")` for details. 1652 1653* All Geoms, Stats and Positions are now exported, so you can inherit from them 1654 when making your own objects (#989). 1655 1656* ggplot2 no longer uses proto or reference classes. Instead, we now use 1657 ggproto, a new OO system designed specifically for ggplot2. Unlike proto 1658 and RC, ggproto supports clean cross-package inheritance. Creating a new OO 1659 system isn't usually the right way to solve a problem, but I'm pretty sure 1660 it was necessary here. Read more about it in the vignette. 1661 1662* `aes_()` replaces `aes_q()`. It also supports formulas, so the most concise 1663 SE version of `aes(carat, price)` is now `aes_(~carat, ~price)`. You may 1664 want to use this form in packages, as it will avoid spurious `R CMD check` 1665 warnings about undefined global variables. 1666 1667### Text 1668 1669* `geom_text()` has been overhauled to make labelling your data a little 1670 easier. It: 1671 1672 * `nudge_x` and `nudge_y` arguments let you offset labels from their 1673 corresponding points (#1120). 1674 1675 * `check_overlap = TRUE` provides a simple way to avoid overplotting 1676 of labels: labels that would otherwise overlap are omitted (#1039). 1677 1678 * `hjust` and `vjust` can now be character vectors: "left", "center", 1679 "right", "bottom", "middle", "top". New options include "inward" and 1680 "outward" which align text towards and away from the center of the plot 1681 respectively. 1682 1683* `geom_label()` works like `geom_text()` but draws a rounded rectangle 1684 underneath each label (#1039). This is useful when you want to label plots 1685 that are dense with data. 1686 1687### Deprecated features 1688 1689* The little used `aes_auto()` has been deprecated. 1690 1691* `aes_q()` has been replaced with `aes_()` to be consistent with SE versions 1692 of NSE functions in other packages. 1693 1694* The `order` aesthetic is officially deprecated. It never really worked, and 1695 was poorly documented. 1696 1697* The `stat` and `position` arguments to `qplot()` have been deprecated. 1698 `qplot()` is designed for quick plots - if you need to specify position 1699 or stat, use `ggplot()` instead. 1700 1701* The theme setting `axis.ticks.margin` has been deprecated: now use the margin 1702 property of `axis.text`. 1703 1704* `stat_abline()`, `stat_hline()` and `stat_vline()` have been removed: 1705 these were never suitable for use other than with `geom_abline()` etc 1706 and were not documented. 1707 1708* `show_guide` has been renamed to `show.legend`: this more accurately 1709 reflects what it does (controls appearance of layer in legend), and uses the 1710 same convention as other ggplot2 arguments (i.e. a `.` between names). 1711 (Yes, I know that's inconsistent with function names with use `_`, but it's 1712 too late to change now.) 1713 1714A number of geoms have been renamed to be internally consistent: 1715 1716* `stat_binhex()` and `stat_bin2d()` have been renamed to `stat_bin_hex()` 1717 and `stat_bin_2d()` (#1274). `stat_summary2d()` has been renamed to 1718 `stat_summary_2d()`, `geom_density2d()`/`stat_density2d()` has been renamed 1719 to `geom_density_2d()`/`stat_density_2d()`. 1720 1721* `stat_spoke()` is now `geom_spoke()` since I realised it's a 1722 reparameterisation of `geom_segment()`. 1723 1724* `stat_bindot()` has been removed because it's so tightly coupled to 1725 `geom_dotplot()`. If you happened to use `stat_bindot()`, just change to 1726 `geom_dotplot()` (#1194). 1727 1728All defunct functions have been removed. 1729 1730### Default appearance 1731 1732* The default `theme_grey()` background colour has been changed from "grey90" 1733 to "grey92": this makes the background a little less visually prominent. 1734 1735* Labels and titles have been tweaked for readability: 1736 1737 * Axes labels are darker. 1738 1739 * Legend and axis titles are given the same visual treatment. 1740 1741 * The default font size dropped from 12 to 11. You might be surprised that 1742 I've made the default text size smaller as it was already hard for 1743 many people to read. It turns out there was a bug in RStudio (fixed in 1744 0.99.724), that shrunk the text of all grid based graphics. Once that 1745 was resolved the defaults seemed too big to my eyes. 1746 1747 * More spacing between titles and borders. 1748 1749 * Default margins scale with the theme font size, so the appearance at 1750 larger font sizes should be considerably improved (#1228). 1751 1752* `alpha` now affects both fill and colour aesthetics (#1371). 1753 1754* `element_text()` gains a margins argument which allows you to add additional 1755 padding around text elements. To help see what's going on use `debug = TRUE` 1756 to display the text region and anchors. 1757 1758* The default font size in `geom_text()` has been decreased from 5mm (14 pts) 1759 to 3.8 mm (11 pts) to match the new default theme sizes. 1760 1761* A diagonal line is no longer drawn on bar and rectangle legends. Instead, the 1762 border has been tweaked to be more visible, and more closely match the size of 1763 line drawn on the plot. 1764 1765* `geom_pointrange()` and `geom_linerange()` get vertical (not horizontal) 1766 lines in the legend (#1389). 1767 1768* The default line `size` for `geom_smooth()` has been increased from 0.5 to 1 1769 to make it easier to see when overlaid on data. 1770 1771* `geom_bar()` and `geom_rect()` use a slightly paler shade of grey so they 1772 aren't so visually heavy. 1773 1774* `geom_boxplot()` now colours outliers the same way as the boxes. 1775 1776* `geom_point()` now uses shape 19 instead of 16. This looks much better on 1777 the default Linux graphics device. (It's very slightly smaller than the old 1778 point, but it shouldn't affect any graphics significantly) 1779 1780* Sizes in ggplot2 are measured in mm. Previously they were converted to pts 1781 (for use in grid) by multiplying by 72 / 25.4. However, grid uses printer's 1782 points, not Adobe (big pts), so sizes are now correctly multiplied by 1783 72.27 / 25.4. This is unlikely to noticeably affect display, but it's 1784 technically correct (<https://youtu.be/hou0lU8WMgo>). 1785 1786* The default legend will now allocate multiple rows (if vertical) or 1787 columns (if horizontal) in order to make a legend that is more likely to 1788 fit on the screen. You can override with the `nrow`/`ncol` arguments 1789 to `guide_legend()` 1790 1791 ```R 1792 p <- ggplot(mpg, aes(displ,hwy, colour = model)) + geom_point() 1793 p 1794 p + theme(legend.position = "bottom") 1795 # Previous behaviour 1796 p + guides(colour = guide_legend(ncol = 1)) 1797 ``` 1798 1799### New and updated themes 1800 1801* New `theme_void()` is completely empty. It's useful for plots with non- 1802 standard coordinates or for drawings (@jiho, #976). 1803 1804* New `theme_dark()` has a dark background designed to make colours pop out 1805 (@jiho, #1018) 1806 1807* `theme_minimal()` became slightly more minimal by removing the axis ticks: 1808 labels now line up directly beneath grid lines (@tomschloss, #1084) 1809 1810* New theme setting `panel.ontop` (logical) make it possible to place 1811 background elements (i.e., gridlines) on top of data. Best used with 1812 transparent `panel.background` (@noamross. #551). 1813 1814### Labelling 1815 1816The facet labelling system was updated with many new features and a 1817more flexible interface (@lionel-). It now works consistently across 1818grid and wrap facets. The most important user visible changes are: 1819 1820* `facet_wrap()` gains a `labeller` option (#25). 1821 1822* `facet_grid()` and `facet_wrap()` gain a `switch` argument to 1823 display the facet titles near the axes. When switched, the labels 1824 become axes subtitles. `switch` can be set to "x", "y" or "both" 1825 (the latter only for grids) to control which margin is switched. 1826 1827The labellers (such as `label_value()` or `label_both()`) also get 1828some new features: 1829 1830* They now offer the `multi_line` argument to control whether to 1831 display composite facets (those specified as `~var1 + var2`) on one 1832 or multiple lines. 1833 1834* In `label_bquote()` you now refer directly to the names of 1835 variables. With this change, you can create math expressions that 1836 depend on more than one variable. This math expression can be 1837 specified either for the rows or the columns and you can also 1838 provide different expressions to each margin. 1839 1840 As a consequence of these changes, referring to `x` in backquoted 1841 expressions is deprecated. 1842 1843* Similarly to `label_bquote()`, `labeller()` now take `.rows` and 1844 `.cols` arguments. In addition, it also takes `.default`. 1845 `labeller()` is useful to customise how particular variables are 1846 labelled. The three additional arguments specify how to label the 1847 variables are not specifically mentioned, respectively for rows, 1848 columns or both. This makes it especially easy to set up a 1849 project-wide labeller dispatcher that can be reused across all your 1850 plots. See the documentation for an example. 1851 1852* The new labeller `label_context()` adapts to the number of factors 1853 facetted over. With a single factor, it displays only the values, 1854 just as before. But with multiple factors in a composite margin 1855 (e.g. with `~cyl + am`), the labels are passed over to 1856 `label_both()`. This way the variables names are displayed with the 1857 values to help identifying them. 1858 1859On the programming side, the labeller API has been rewritten in order 1860to offer more control when faceting over multiple factors (e.g. with 1861formulae such as `~cyl + am`). This also means that if you have 1862written custom labellers, you will need to update them for this 1863version of ggplot. 1864 1865* Previously, a labeller function would take `variable` and `value` 1866 arguments and return a character vector. Now, they take a data frame 1867 of character vectors and return a list. The input data frame has one 1868 column per factor facetted over and each column in the returned list 1869 becomes one line in the strip label. See documentation for more 1870 details. 1871 1872* The labels received by a labeller now contain metadata: their margin 1873 (in the "type" attribute) and whether they come from a wrap or a 1874 grid facet (in the "facet" attribute). 1875 1876* Note that the new `as_labeller()` function operator provides an easy 1877 way to transform an existing function to a labeller function. The 1878 existing function just needs to take and return a character vector. 1879 1880## Documentation 1881 1882* Improved documentation for `aes()`, `layer()` and much much more. 1883 1884* I've tried to reduce the use of `...` so that you can see all the 1885 documentation in one place rather than having to integrate multiple pages. 1886 In some cases this has involved adding additional arguments to geoms 1887 to make it more clear what you can do: 1888 1889 * `geom_smooth()` gains explicit `method`, `se` and `formula` arguments. 1890 1891 * `geom_histogram()` gains `binwidth`, `bins`, `origin` and `right` 1892 arguments. 1893 1894 * `geom_jitter()` gains `width` and `height` arguments to make it easier 1895 to control the amount of jittering without using the lengthy 1896 `position_jitter()` function (#1116) 1897 1898* Use of `qplot()` in examples has been minimised (#1123, @hrbrmstr). This is 1899 inline with the 2nd edition of the ggplot2 box, which minimises the use of 1900 `qplot()` in favour of `ggplot()`. 1901 1902* Tighly linked geoms and stats (e.g. `geom_boxplot()` and `stat_boxplot()`) 1903 are now documented in the same file so you can see all the arguments in one 1904 place. Variations of the same idea (e.g. `geom_path()`, `geom_line()`, and 1905 `geom_step()`) are also documented together. 1906 1907* It's now obvious that you can set the `binwidth` parameter for 1908 `stat_bin_hex()`, `stat_summary_hex()`, `stat_bin_2d()`, and 1909 `stat_summary_2d()`. 1910 1911* The internals of positions have been cleaned up considerably. You're unlikely 1912 to notice any external changes, although the documentation should be a little 1913 less confusing since positions now don't list parameters they never use. 1914 1915## Data 1916 1917* All datasets have class `tbl_df` so if you also use dplyr, you get a better 1918 print method. 1919 1920* `economics` has been brought up to date to 2015-04-01. 1921 1922* New `economics_long` is the economics data in long form. 1923 1924* New `txhousing` dataset containing information about the Texas housing 1925 market. Useful for examples that need multiple time series, and for 1926 demonstrating model+vis methods. 1927 1928* New `luv_colours` dataset which contains the locations of all 1929 built-in `colors()` in Luv space. 1930 1931* `movies` has been moved into its own package, ggplot2movies, because it was 1932 large and not terribly useful. If you've used the movies dataset, you'll now 1933 need to explicitly load the package with `library(ggplot2movies)`. 1934 1935## Bug fixes and minor improvements 1936 1937* All partially matched arguments and `$` have been been replaced with 1938 full matches (@jimhester, #1134). 1939 1940* ggplot2 now exports `alpha()` from the scales package (#1107), and `arrow()` 1941 and `unit()` from grid (#1225). This means you don't need attach scales/grid 1942 or do `scales::`/`grid::` for these commonly used functions. 1943 1944* `aes_string()` now only parses character inputs. This fixes bugs when 1945 using it with numbers and non default `OutDec` settings (#1045). 1946 1947* `annotation_custom()` automatically adds a unique id to each grob name, 1948 making it easier to plot multiple grobs with the same name (e.g. grobs of 1949 ggplot2 graphics) in the same plot (#1256). 1950 1951* `borders()` now accepts xlim and ylim arguments for specifying the geographical 1952 region of interest (@markpayneatwork, #1392). 1953 1954* `coord_cartesian()` applies the same expansion factor to limits as for scales. 1955 You can suppress with `expand = FALSE` (#1207). 1956 1957* `coord_trans()` now works when breaks are suppressed (#1422). 1958 1959* `cut_number()` gives error message if the number of requested bins can 1960 be created because there are two few unique values (#1046). 1961 1962* Character labels in `facet_grid()` are no longer (incorrectly) coerced into 1963 factors. This caused problems with custom label functions (#1070). 1964 1965* `facet_wrap()` and `facet_grid()` now allow you to use non-standard 1966 variable names by surrounding them with backticks (#1067). 1967 1968* `facet_wrap()` more carefully checks its `nrow` and `ncol` arguments 1969 to ensure that they're specified correctly (@richierocks, #962) 1970 1971* `facet_wrap()` gains a `dir` argument to control the direction the 1972 panels are wrapped in. The default is "h" for horizontal. Use "v" for 1973 vertical layout (#1260). 1974 1975* `geom_abline()`, `geom_hline()` and `geom_vline()` have been rewritten to 1976 have simpler behaviour and be more consistent: 1977 1978 * `stat_abline()`, `stat_hline()` and `stat_vline()` have been removed: 1979 these were never suitable for use other than with `geom_abline()` etc 1980 and were not documented. 1981 1982 * `geom_abline()`, `geom_vline()` and `geom_hline()` are bound to 1983 `stat_identity()` and `position_identity()` 1984 1985 * Intercept parameters can no longer be set to a function. 1986 1987 * They are all documented in one file, since they are so closely related. 1988 1989* `geom_bin2d()` will now let you specify one dimension's breaks exactly, 1990 without touching the other dimension's default breaks at all (#1126). 1991 1992* `geom_crossbar()` sets grouping correctly so you can display multiple 1993 crossbars on one plot. It also makes the default `fatten` argument a little 1994 bigger to make the middle line more obvious (#1125). 1995 1996* `geom_histogram()` and `geom_smooth()` now only inform you about the 1997 default values once per layer, rather than once per panel (#1220). 1998 1999* `geom_pointrange()` gains `fatten` argument so you can control the 2000 size of the point relative to the size of the line. 2001 2002* `geom_segment()` annotations were not transforming with scales 2003 (@BrianDiggs, #859). 2004 2005* `geom_smooth()` is no longer so chatty. If you want to know what the deafult 2006 smoothing method is, look it up in the documentation! (#1247) 2007 2008* `geom_violin()` now has the ability to draw quantile lines (@DanRuderman). 2009 2010* `ggplot()` now captures the parent frame to use for evaluation, 2011 rather than always defaulting to the global environment. This should 2012 make ggplot more suitable to use in more situations (e.g. with knitr) 2013 2014* `ggsave()` has been simplified a little to make it easier to maintain. 2015 It no longer checks that you're printing a ggplot2 object (so now also 2016 works with any grid grob) (#970), and always requires a filename. 2017 Parameter `device` now supports character argument to specify which supported 2018 device to use ('pdf', 'png', 'jpeg', etc.), for when it cannot be correctly 2019 inferred from the file extension (for example when a temporary filename is 2020 supplied server side in shiny apps) (@sebkopf, #939). It no longer opens 2021 a graphics device if one isn't already open - this is annoying when you're 2022 running from a script (#1326). 2023 2024* `guide_colorbar()` creates correct legend if only one color (@krlmlr, #943). 2025 2026* `guide_colorbar()` no longer fails when the legend is empty - previously 2027 this often masked misspecifications elsewhere in the plot (#967). 2028 2029* New `layer_data()` function extracts the data used for plotting for a given 2030 layer. It's mostly useful for testing. 2031 2032* User supplied `minor_breaks` can now be supplied on the same scale as 2033 the data, and will be automatically transformed with by scale (#1385). 2034 2035* You can now suppress the appearance of an axis/legend title (and the space 2036 that would allocated for it) with `NULL` in the `scale_` function. To 2037 use the default lable, use `waiver()` (#1145). 2038 2039* Position adjustments no longer warn about potentially varying ranges 2040 because the problem rarely occurs in practice and there are currently a 2041 lot of false positives since I don't understand exactly what FP criteria 2042 I should be testing. 2043 2044* `scale_fill_grey()` now uses red for missing values. This matches 2045 `scale_colour_grey()` and makes it obvious where missing values lie. 2046 Override with `na.value`. 2047 2048* `scale_*_gradient2()` defaults to using Lab colour space. 2049 2050* `scale_*_gradientn()` now allows `colours` or `colors` (#1290) 2051 2052* `scale_y_continuous()` now also transforms the `lower`, `middle` and `upper` 2053 aesthetics used by `geom_boxplot()`: this only affects 2054 `geom_boxplot(stat = "identity")` (#1020). 2055 2056* Legends no longer inherit aesthetics if `inherit.aes` is FALSE (#1267). 2057 2058* `lims()` makes it easy to set the limits of any axis (#1138). 2059 2060* `labels = NULL` now works with `guide_legend()` and `guide_colorbar()`. 2061 (#1175, #1183). 2062 2063* `override.aes` now works with American aesthetic spelling, e.g. color 2064 2065* Scales no longer round data points to improve performance of colour 2066 palettes. Instead the scales package now uses a much faster colour 2067 interpolation algorithm (#1022). 2068 2069* `scale_*_brewer()` and `scale_*_distiller()` add new `direction` argument of 2070 `scales::brewer_pal`, making it easier to change the order of colours 2071 (@jiho, #1139). 2072 2073* `scale_x_date()` now clips dates outside the limits in the same way as 2074 `scale_x_continuous()` (#1090). 2075 2076* `stat_bin()` gains `bins` arguments, which denotes the number of bins. Now 2077 you can set `bins=100` instead of `binwidth=0.5`. Note that `breaks` or 2078 `binwidth` will override it (@tmshn, #1158, #102). 2079 2080* `stat_boxplot()` warns if a continuous variable is used for the `x` aesthetic 2081 without also supplying a `group` aesthetic (#992, @krlmlr). 2082 2083* `stat_summary_2d()` and `stat_bin_2d()` now share exactly the same code for 2084 determining breaks from `bins`, `binwidth`, and `origin`. 2085 2086* `stat_summary_2d()` and `stat_bin_2d()` now output in tile/raster compatible 2087 form instead of rect compatible form. 2088 2089* Automatically computed breaks do not lead to an error for transformations like 2090 "probit" where the inverse can map to infinity (#871, @krlmlr) 2091 2092* `stat_function()` now always evaluates the function on the original scale. 2093 Previously it computed the function on transformed scales, giving incorrect 2094 values (@BrianDiggs, #1011). 2095 2096* `strip_dots` works with anonymous functions within calculated aesthetics 2097 (e.g. `aes(sapply(..density.., function(x) mean(x))))` (#1154, @NikNakk) 2098 2099* `theme()` gains `validate = FALSE` parameter to turn off validation, and 2100 hence store arbitrary additional data in the themes. (@tdhock, #1121) 2101 2102* Improved the calculation of segments needed to draw the curve representing 2103 a line when plotted in polar coordinates. In some cases, the last segment 2104 of a multi-segment line was not drawn (@BrianDiggs, #952) 2105