Skip to content

Commit 1b3d485

Browse files
committed
Merge branch 'ropensci-master'
2 parents be2dfc1 + 69d6149 commit 1b3d485

Some content is hidden

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

83 files changed

+420
-272
lines changed

DESCRIPTION

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create Interactive Web Graphics via 'plotly.js'
3-
Version: 4.9.2.9000
3+
Version: 4.9.3.9000
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]", comment = c(ORCID = "0000-0002-4958-2844")),
66
person("Chris", "Parmer", role = "aut",
@@ -20,7 +20,7 @@ Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
2020
person("Plotly Technologies Inc.", role = "cph"))
2121
License: MIT + file LICENSE
2222
Description: Create interactive web graphics from 'ggplot2' graphs and/or a custom interface to the (MIT-licensed) JavaScript library 'plotly.js' inspired by the grammar of graphics.
23-
URL: https://plotly-r.com, https://github.com/ropensci/plotly#readme, https://plot.ly/r
23+
URL: https://plotly-r.com, https://github.com/ropensci/plotly#readme, https://plotly.com/r/
2424
BugReports: https://github.com/ropensci/plotly/issues
2525
Depends:
2626
R (>= 3.2.0),
@@ -42,7 +42,7 @@ Imports:
4242
vctrs,
4343
tibble,
4444
lazyeval (>= 0.2.0),
45-
rlang,
45+
rlang (>= 0.4.10),
4646
crosstalk,
4747
purrr,
4848
data.table,
@@ -74,7 +74,6 @@ Suggests:
7474
processx,
7575
plotlyGeoAssets,
7676
forcats,
77-
thematic,
7877
palmerpenguins
7978
LazyData: true
8079
RoxygenNote: 7.1.1

NEWS.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ This is minor patch release with a few minor bug fixes and updates test expectat
3636
## BUG FIXES
3737

3838
=======
39-
# 4.9.2.9000
39+
# 4.9.3.9000
40+
41+
## BUG FIXES
42+
43+
* Duplicate `highlight(selectize=T)` dropdowns are no longer rendered in Shiny (#1936).
44+
* `group_by.plotly()` now properly retains crosstalk information across `{dplyr}` versions (#1920).
45+
* Adds fixes in `ggplotly()` for the upcoming `{ggplot2}` >3.3.3 release (#1952).
46+
* Fixes some issues with `name` and `frames` when both attributes are specified. (#1903 and #1618).
47+
48+
# 4.9.3
4049

4150
## Changes to plotly.js
4251

@@ -46,7 +55,7 @@ This is minor patch release with a few minor bug fixes and updates test expectat
4655

4756
* `renderPlotly()` now works well with `shiny::bindCache()`, meaning that plotly graphs can now be persistently cached in Shiny apps with `renderPlotly(expr) %>% shiny::bindCache()` (#1879).
4857

49-
* `ggplotly()` now works well with the [**thematic** package](https://rstudio.github.io/thematic). That is, it can now correctly translate **ggplot2** styling that derives from **thematic**. Note that, in order to use **thematic**'s auto theming in Shiny with `ggplotly()`, you need **shiny** v1.5.0 (or higher) and **htmlwidgets** v1.5.2.9000 (or higher). Relatedly, if these versions are available, one may now also call `getCurrentOutputInfo()` inside `renderPlotly()` to get CSS styles of the output container (#1801 and #1802).
58+
* `ggplotly()` now works well with the [**thematic** package](https://rstudio.github.io/thematic/). That is, it can now correctly translate **ggplot2** styling that derives from **thematic**. Note that, in order to use **thematic**'s auto theming in Shiny with `ggplotly()`, you need **shiny** v1.5.0 (or higher) and **htmlwidgets** v1.5.2.9000 (or higher). Relatedly, if these versions are available, one may now also call `getCurrentOutputInfo()` inside `renderPlotly()` to get CSS styles of the output container (#1801 and #1802).
5059

5160
## IMPROVEMENTS
5261

@@ -124,7 +133,7 @@ This is minor patch release with a few minor bug fixes and updates test expectat
124133

125134
## NEW FEATURES & IMPROVEMENTS
126135

127-
* Several new features and improvements related to accessing plotly.js events in shiny (learn more about them in this RStudio [webinar](https://resources.rstudio.com/webinars/accessing-and-responding-to-plotly-events-in-shiny-carson-sievert)):
136+
* Several new features and improvements related to accessing plotly.js events in shiny (learn more about them in this RStudio [webinar](https://rstudio.com/resources/webinars/accessing-and-responding-to-plotly-events-in-shiny/)):
128137
* The `event` argument of the `event_data()` function now supports the following events: `plotly_selecting`, `plotly_brushed`, `plotly_brushing`, `plotly_restyle`, `plotly_legendclick`, `plotly_legenddoubleclick`, `plotly_clickannotation`, `plotly_afterplot`, `plotly_doubleclick`, `plotly_deselect`, `plotly_unhover`. For examples, see `plotly_example("shiny", "event_data")`, `plotly_example("shiny", "event_data_legends")`, and `plotly_example("shiny", "event_data_annotation")`,
129138
* New `event_register()` and `event_unregister()` functions for declaring which events to transmit over the wire (i.e., from the browser to the shiny server). Events that are likely to have large overhead are not registered by default, so you'll need to register these: `plotly_selecting`, `plotly_unhover`, `plotly_restyle`, `plotly_legendclick`, and `plotly_legenddoubleclick`.
130139
* A new `priority` argument. By setting `priority='event'`, the `event` is treated like a true event: any reactive expression using the `event` becomes invalidated (regardless of whether the input values has changed). For an example, see `plotly_example("shiny", "event_priority")`.
@@ -206,7 +215,7 @@ This is minor patch release with a few minor bug fixes and updates test expectat
206215
* The `name` attribute is now a "special `plot_ly()` argument" and behaves similar to `split` (it ensures a different trace for every unique value supplied). Although this leads to a breaking change (`name` was previously appended to an automatically generated trace name), it leads to a more flexible and transparent API. Those that wish to have the old behavior back should provide relevant mappings to the `name` attributes (e.g. `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~factor(vs), name = "a")` should become `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~factor(vs), name = ~paste(vs, "\na"))`)
207216
* The `color` argument now maps to `fillcolor`, making it much easier to use polygon fills to encode data values (e.g., choropleth maps). For backwards-compatibilty reasons, when `color` maps to `fillcolor`, `alpha` defaults to 0.5 (instead of 1). For an example, `plot_mapbox(mn_res, color = ~INDRESNAME)` or `plot_mapbox(mn_res, split = ~INDRESNAME, color = ~AREA, showlegend = FALSE, stroke = I("black"))`.
208217
* The `color` argument no longer automatically add `"markers"` to the `mode` attribute for scatter/scattergl trace types. Those who wish to have the old behavior back, should add `"markers"` to the `mode` explicity (e.g., change `plot_ly(economics, x = ~pce, y = ~pop, color = ~as.numeric(date), mode = "lines")` to `plot_ly(economics, x = ~pce, y = ~pop, color = ~as.numeric(date), mode = "lines+markers")`).
209-
* The `size` argument now informs a default [error_[x/y].width](https://plot.ly/r/reference/#scatter-error_x-width) (and `span` informs [error_[x/y].thickness](https://plot.ly/r/reference/#scatter-error_x-thickness)). Note you can override the default by specifying directly (e.g. `plot_ly(x = 1:10, y = 1:10, size = I(10), error_x = list(value = 5, width = 0))`).
218+
* The `size` argument now informs a default [error_[x/y].width](https://plotly.com/r/reference/#scatter-error_x-width) (and `span` informs [error_[x/y].thickness](https://plotly.com/r/reference/#scatter-error_x-thickness)). Note you can override the default by specifying directly (e.g. `plot_ly(x = 1:10, y = 1:10, size = I(10), error_x = list(value = 5, width = 0))`).
210219
* `layout.showlegend` now defaults to `TRUE` for a *single* pie trace. This is a more sensible default and matches pure plotly.js behavior.
211220

212221
### Other changes relevant for all **plotly** objects
@@ -287,18 +296,18 @@ This is minor patch release with a few minor bug fixes and updates test expectat
287296

288297
## NEW FEATURES & IMPROVEMENTS
289298

290-
* Added a significant amount of support for "multiple linked views". For some relatively basic examples, see the demos (the ones prefixed with "highlight" are most relevant) -- `demo(package = "plotly")`. For a more comprehensive overview, see <https://cpsievert.github.io/plotly_book/linking-views-without-shiny.html>. For some more complex examples, see <https://cpsievert.github.io/pedestrians/>
299+
* Added a significant amount of support for "multiple linked views". For some relatively basic examples, see the demos (the ones prefixed with "highlight" are most relevant) -- `demo(package = "plotly")`. For a more comprehensive overview, see <https://plotly-r.com/client-side-linking.html>. For some more complex examples, see <https://pedestrians.cpsievert.me/>
291300
* Added the `highlight()` function for configuring selection modes/sequences/options.
292-
* Added support for animation. For some relatively basic examples, see the examples section of `help(animation)`. For a more thorough overview, see <https://cpsievert.github.io/plotly_book/key-frame-animations.html>
301+
* Added support for animation. For some relatively basic examples, see the examples section of `help(animation)`. For a more thorough overview, see <https://plotly-r.com/animating-views.html>
293302
* Added a `frame` argument to `plot_ly()` for creating animations. Also added the `animation_opts()`, `animation_slider()`, and `animation_button()` functions for configuring animation defaults.
294303
* Added a new interface to [v2 of the REST API](https://api.plot.ly/v2). This new interface makes the `plotly_POST()` and `get_figure()` functions obsolete (use `api_create()` and `api_download_plot()` instead), and thus, are now deprecated, but remain around for backwards-compatibility. For more details, see `help(api)`.
295304
* Added support for conversion of more **ggplot2** geoms via `ggplotly()`: `GeomCol`, `GeomRug`, `GeomCrossbar`, `GeomQuantile`, `GeomSpoke`, `GeomDotplot`, `GeomRasterAnn` (i.e., `annotation_raster()`), and `GeomAnnotationMap` (i.e., `annotation_map()`).
296-
* Added a new function `raster2uri()` which makes it easier to embed raster objects as [images](https://plot.ly/r/reference/#layout-images) via data URIs. For examples, see `help(raster2uri)`.
305+
* Added a new function `raster2uri()` which makes it easier to embed raster objects as [images](https://plotly.com/r/reference/#layout-images) via data URIs. For examples, see `help(raster2uri)`.
297306
* `ggplotly()` gains a new argument, `dynamicTicks`, which allows axis ticks to update upon zoom/pan interactions (fixes #485).
298307
* Sensible sizing and positioning defaults are now provided for subplots multiple colorbars.
299308
* R linebreaks are translated to HTML linebreaks (i.e., '\n' translates to '<br />') (fixes #851).
300309
* Added a `plot_dendro()` function for a quick and dirty interactive dendrogram with support for hierarchial selection. For more, see -- <https://plotly-r.com/client-side-linking.html#fig:dendro>
301-
* The `export()` function gains a `selenium` argument for rendering/exporting WebGL plots and exporting to 'svg'/'webp' file formats (via the plotly.js function [Plotly.downloadImage()](https://plot.ly/javascript/plotlyjs-function-reference/#plotlydownloadimage)).
310+
* The `export()` function gains a `selenium` argument for rendering/exporting WebGL plots and exporting to 'svg'/'webp' file formats (via the plotly.js function [Plotly.downloadImage()](https://plotly.com/javascript/plotlyjs-function-reference/#plotlydownloadimage)).
302311
* Better type checking of trace attributes will now automatically reduce a single-valued vector to a constant (when appropriate). This is particularly useful for anchoring multiple traces to a single legend entry via `legendgroup` (see #675, #817, #826).
303312
* The `plotlyOutput()` function gains a `inline` argument which makes it easier to place multiple plots in the same row (in a shiny application).
304313

@@ -392,14 +401,14 @@ limits.
392401

393402
## NEW FEATURES
394403

395-
* Added the `plot_mapbox()` and `plot_geo()` functions, which make it easier to work with the "scattermapbox", "scattergeo", and "choropleth" trace types. See the maps chapter of the plotly book for some examples -- <https://cpsievert.github.io/plotly_book/maps.html>
404+
* Added the `plot_mapbox()` and `plot_geo()` functions, which make it easier to work with the "scattermapbox", "scattergeo", and "choropleth" trace types. See the maps chapter of the plotly book for some examples -- <https://plotly-r.com/maps.html>
396405
* `subplot()` now accepts, and correctly scales mapbox objects.
397406
* Added the `add_mesh3d()` and `add_pie()` functions as wrappers around the "mesh3d", and "pie" trace types.
398407

399408
## CHANGES
400409

401410
* The `add_scattergeo()` and `add_choropleth()` functions have been deprecated in favor of `plot_geo()`.
402-
* The `add_area(...)` function changed it's meaning from `add_lines(..., fill = 'tozeroy')` to a wrapper around the area trace <https://plot.ly/r/reference/#area>. This is more consistent with the naming conventions already in place for other `add_()` functions.
411+
* The `add_area(...)` function changed it's meaning from `add_lines(..., fill = 'tozeroy')` to a wrapper around the area trace <https://plotly.com/r/reference/#area>. This is more consistent with the naming conventions already in place for other `add_()` functions.
403412
* `add_ribbons()` now shows points (instead of fill) on hover.
404413

405414
# 4.4.5 -- 19 September 2016
@@ -482,7 +491,7 @@ limits.
482491

483492
## CHANGES
484493

485-
* vignettes were removed and that documentation will now be hosted at <https://cpsievert.github.io/plotly_book/>
494+
* vignettes were removed and that documentation will now be hosted at <https://plotly.com/r/>
486495

487496
## BUG FIXES
488497

R/add.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ add_data <- function(p, data = NULL) {
3535
#' @seealso [plot_ly()]
3636
#' @references \url{https://plotly-r.com/overview.html}
3737
#'
38-
#' \url{https://plot.ly/r}
38+
#' \url{https://plotly.com/r/}
3939
#'
40-
#' \url{https://plot.ly/r/reference/}
40+
#' \url{https://plotly.com/r/reference/}
4141
#' @author Carson Sievert
4242
#' @export
4343
#' @rdname add_trace

R/animate.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#' }
5858
#'
5959
#'
60-
#' #' # for more, see https://cpsievert.github.io/plotly_book/key-frame-animations.html
60+
#' #' # for more, see https://plotly.com/r/animating-views.html
6161
#'
6262
animation_opts <- function(p, frame = 500, transition = frame, easing = "linear",
6363
redraw = TRUE, mode = "immediate") {

R/deprecated.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ get_figure <- function(username, id) {
4848
#'
4949
#' @description This function is now deprecated. It used to provide a way to store plotly
5050
#' account credentials, but that can now be done with environment variables.
51-
#' For more details and examples, see \url{https://plot.ly/r/getting-started/}.
51+
#' For more details and examples, see \url{https://plotly.com/r/getting-started/}.
5252
#'
5353
#' If you're here looking for an intro/overview of the package, see the
5454
#' \href{https://github.com/ropensci/plotly/#getting-started}{readme}

R/ggplotly.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#' @param ... arguments passed onto methods.
3333
#' @export
3434
#' @author Carson Sievert
35-
#' @references \url{https://plot.ly/ggplot2}
35+
#' @references \url{https://plotly.com/ggplot2/}
3636
#' @seealso [plot_ly()]
3737
#' @examples \dontrun{
3838
#' # simple example
@@ -431,8 +431,8 @@ gg2list <- function(p, width = NULL, height = NULL,
431431

432432
# Allow thematic to add new defaults to the plot object based on it's theme
433433
built <- if (isNamespaceLoaded("thematic")) {
434-
ggthematic_build <- getFromNamespace("ggthematic_build", "thematic")
435-
ggthematic_build(p, ggplotly_build, thematic::thematic_get_theme(resolve = TRUE))
434+
tns <- asNamespace("thematic")
435+
tns$ggthematic_build(p, ggplotly_build, tns$thematic_get_theme(resolve = TRUE))
436436
} else {
437437
ggplotly_build(p)
438438
}
@@ -1099,7 +1099,7 @@ gg2list <- function(p, width = NULL, height = NULL,
10991099
# start build a plotly object with meta information about the ggplot
11001100
# first, translate layer mappings -> plotly attrs
11011101
mappingFormulas <- lapply(layers, function(x) {
1102-
mappings <- c(x$mapping, if (isTRUE(x$inherit.aes)) plot$mapping)
1102+
mappings <- getAesMap(plot, x)
11031103
if (originalData) {
11041104
lapply(mappings, lazyeval::f_new)
11051105
} else {
@@ -1277,7 +1277,7 @@ font_family <- function(family = "") {
12771277
if (!isNamespaceLoaded("thematic")) {
12781278
return("")
12791279
}
1280-
font <- thematic::thematic_get_option("font")
1280+
font <- asNamespace("thematic")$thematic_get_option("font", resolve = TRUE)
12811281
if (!length(font)) {
12821282
return("")
12831283
}
@@ -1427,3 +1427,12 @@ gdef2trace <- function(gdef, theme, gglayout) {
14271427
NULL
14281428
}
14291429
}
1430+
1431+
1432+
getAesMap <- function(plot, layer) {
1433+
if (isTRUE(layer$inherit.aes)) {
1434+
modify_list(plot$mapping, layer$mapping)
1435+
} else {
1436+
layer$mapping
1437+
}
1438+
}

R/group2NA.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#' (i.e., color, fill, etc), it is more efficient to draw them as a single trace
88
#' with missing values that separate the groups (instead of multiple traces),
99
#' In this case, one should also take care to make sure
10-
#' \href{https://plot.ly/r/reference/#scatter-connectgaps}{connectgaps}
10+
#' \href{https://plotly.com/r/reference/#scatter-connectgaps}{connectgaps}
1111
#' is set to `FALSE`.
1212
#'
1313
#' @param data a data frame.
@@ -72,7 +72,7 @@ group2NA <- function(data, groupNames = "group", nested = NULL, ordered = NULL,
7272
data.table::setorderv(dt, cols = c(nested, groupNames, ordered))
7373

7474
# when connectgaps=FALSE, inserting NAs ensures each "group"
75-
# will be visually distinct https://plot.ly/r/reference/#scatter-connectgaps
75+
# will be visually distinct https://plotly.com/r/reference/#scatter-connectgaps
7676
# also, retracing is useful for creating polygon(s) via scatter trace(s)
7777
keyVars <- c(nested, groupNames)
7878
keyNum <- length(keyVars) + 1

R/helpers.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' @param p a plotly object
44
#' @param ... arguments are documented here
5-
#' \url{https://plot.ly/r/reference/#scatter-marker-colorbar}.
5+
#' \url{https://plotly.com/r/reference/#scatter-marker-colorbar}.
66
#' @param limits numeric vector of length 2. Set the extent of the colorbar scale.
77
#' @param which colorbar to modify? Should only be relevant for subplots with
88
#' multiple colorbars.
@@ -13,7 +13,7 @@
1313
#' p <- plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~cyl)
1414
#'
1515
#' # pass any colorbar attribute --
16-
#' # https://plot.ly/r/reference/#scatter-marker-colorbar
16+
#' # https://plotly.com/r/reference/#scatter-marker-colorbar
1717
#' colorbar(p, len = 0.5)
1818
#'
1919
#' # Expand the limits of the colorbar
@@ -188,7 +188,7 @@ plotly_empty <- function(...) {
188188
#' Encode a raster object as a data URI
189189
#'
190190
#' Encode a raster object as a data URI, which is suitable for
191-
#' use with `layout()` \href{https://plot.ly/r/reference/#layout-images}{images}.
191+
#' use with `layout()` \href{https://plotly.com/r/reference/#layout-images}{images}.
192192
#' This is especially convenient for embedding raster images on a plot in
193193
#' a self-contained fashion (i.e., so they don't depend on external URL links).
194194
#'

R/layers2layout.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layers2layout <- function(gglayout, layers, layout) {
33
geoms <- sapply(layers, function(x) class(x[["geom"]])[1])
44
RasterGeom <- which(geoms %in% "GeomRasterAnn")
55
for (i in RasterGeom) {
6-
params <- layers[[i]]$geom_params
6+
params <- layers[[i]]$computed_geom_params %||% layers[[i]]$geom_params
77
for (j in seq_len(nrow(layout))) {
88
lay <- layout[j, ]
99

R/layers2traces.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ layers2traces <- function(data, prestats_data, layout, p) {
66
# Extract parameters (and "hovertext aesthetics") in each layer
77
params <- Map(function(x, y) {
88
param <- c(
9-
y[["geom_params"]], y[["stat_params"]], y[["aes_params"]],
9+
y[["computed_geom_params"]] %||% y[["geom_params"]],
10+
y[["computed_stat_params"]] %||% y[["stat_params"]],
11+
y[["aes_params"]],
1012
position = ggtype(y, "position")
1113
)
1214

13-
# add on plot-level mappings, if they're inherited
14-
map <- c(y$mapping, if (isTRUE(y$inherit.aes)) p$mapping)
15+
map <- getAesMap(p, y)
1516

1617
# consider "calculated" aesthetics (e.g., density, count, etc)
1718
calc_aes <- y$stat$default_aes[ggfun("is_calculated_aes")(y$stat$default_aes)]

0 commit comments

Comments
 (0)