Releases: plotly/plotly.R
plotly 4.9.1
Changes to plotly.js
- This version of the R package upgrades the version of the underlying plotly.js library from v1.46.1 to v1.49.4. The plotly.js release page has the full list of changes.
IMPROVEMENTS
event_data()gains support for theplotly_sunburstclickevent (#1648)
BUG FIXES
- Fixed an issue with correctly capturing the return value of user-expressions to
renderPlotly()(#1528). - Fixed a resizing issue where graphs could be incorrectly resized to their initial size in some cases (#1553).
ggplotly()now positions the x-axis in the last column of afacet_wrap()properly (#1501).ggplotly()now handlesgeom_hline()/geom_vline()correctly in conjunction withcoord_flip()(#1519).event_data()now correctly relays thekeyattribute for statistical traces (#1610).
plotly 4.9.0
Changes to plotly.js
- This version of the R package upgrades the version of the underlying plotly.js library from v1.42.3 to v1.46.1. The plotly.js release page has the full list of changes, but here is summary most pertainent ones for the R package:
- New trace types:
sunburst,waterfall,isosurface. - New
hovertemplateattribute allows for finer-tuned control over tooltip text. See here for an example. - Providing a string to
titleis now deprecated (but still works). Instead, usetitle = list(text = "title"). This change was made to support a new title placement API (e.g.,title = list(text = "title", xanchor = "left")). Note that these changes are relevant forlayout.titleas well aslayout.xaxis.title/layout.yaxis.title/etc.
- New trace types:
NEW FEATURES & IMPROVEMENTS
-
Several new features and improvements related to accessing plotly.js events in shiny (learn more about them in this RStudio webinar):
- The
eventargument of theevent_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, seeplotly_example("shiny", "event_data"),plotly_example("shiny", "event_data_legends"), andplotly_example("shiny", "event_data_annotation"), - New
event_register()andevent_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, andplotly_legenddoubleclick. - A new
priorityargument. By settingpriority='event', theeventis treated like a true event: any reactive expression using theeventbecomes invalidated (regardless of whether the input values has changed). For an example, seeplotly_example("shiny", "event_priority"). - The
event_data()function now relays the (official plotly.js)customdataattribute in similar fashion to (unofficial)keyattribute (#1423). Runplotly_example("shiny", "event_data")for an example. event_data("plotly_selected")is no longer too eager to clear. That is, it is no longer set toNULLwhen clicking on a plot after triggering the "plotly_selected" event (#1121) (#1122).
- The
-
Several new features and improvements for exporting static graphs with the orca command-line utility:
- The
orca()function now supports conversion of much larger figures (#1322) and works without a mapbox api token (#1314). - The
orca_serve()function was added for efficient exporting of many plotly graphs. For examples, seehelp(orca_serve). - The
orca()function gains new argumentsmore_argsand...for finer control over the underlying system commands.
- The
-
ggplotly()now respects horizontal alignment of ggplot2 titles (e.g.,ggplotly(qplot(1:10) + ggtitle("A title") + theme(plot.title = element_text(hjust = 1)))). -
plotly objects can now be serialized and unserialized in different environments (i.e., you can now use
saveRDS()to save an object as an rds file and restore it on another machine withreadRDS()). Note this object is dynamically linked to JavaScript libraries, so one should take care to use consistent versions of plotly when serializing and unserializing (#1376). -
The
style()function now supports "partial updates" (i.e. modification of a particular property of an object, rather than the entire object). For example, notice how the first plot retains the original marker shape (a square):p <- plot_ly(x = 1:10, y = 1:10, symbol = I(15)); subplot(style(p, marker.color = "red"), style(p, marker = list(color = "red")))(#1342). -
The
methodargument ofplotlyProxyInvoke()gains support for a"reconfig"method. This makes it possible to modify just the configuration of a plot in a shiny app. For an example use, seeplotly_example("shiny", "event_data_annotation"). -
The
plotly_example()function will now attempt to open the source file(s) used to run the example. Setedit = FALSEto prevent the source file(s) from opening. -
An informative warning is now thrown if invalid argument names are supplied to
config().
CHANGES
- If
strokeis specified,spannow defaults toI(1). This results in a slightly narrower default span for some trace types (e.g.,box,contour), but it also ensures thestrokeis always visible when it's relevant (e.g.plot_ly(x = 1:10, y = 1:10, stroke = I("black"))), making for a more consistent overall default (#1507). - The 'collaborate' button no longer appears in the modebar, and is longer supported, so the
config()function no longer has acollaborateargument. - The
cloudargument is now deprecated and will be removed in a future version. UseshowSendToCloudinstead. ggplotly()now translates title information tolayout.title.text(instead oflayout.title) andlayout.title.font(instead oflayout.titlefont)
BUG FIXES
subplot()now works much better with annotations, images, and shapes:subplot()now repositions shapes with fixed height/width (i.e.,xsizemode/ysizemodeof"pixel") correctly (#1494).- The
colorscaleattribute now correctly handles a wider range of input values (#1432, #1485) - The colorscale generated via the
colorargument inplot_ly()now uses an evenly spaced grid of values instead of quantiles (#1308). - When using shinytest to test a shiny that contains plotly graph, false positive differences are no longer reported (rstudio/shinytest#174).
- When the
sizeargument maps tomarker.size, it now converts to an array of appropriate length (#1479). - The
colorandstrokearguments now work as expected for trace types withfillcolorbut nofillattribute (e.g.boxtraces) (#1292). - Information emitted by in
event_data()for heatmaps with atomic vectors forx/y/zis now correct (#1141). - Fixed issue where dplyr groups caused a problem in the ordering of data arrays passed to
markerobjects (#1351). - In some cases, a
ggplotly()colorbar would cause issues with hover behavior, which is now fixed (#1381). - An articial marker no longer appears when clearing a crosstalk selection of a plot with a colorbar (#1406).
- Clearing a highlight event via crosstalk no longer deletes all the traces added since initial draw (#1436).
- Recursive attribute validation is now only performed on recursive objects (#1315).
- The
textattribute is no longer collapsed to a string whenhoveron='fills+points'(#1448). layout.[x-y]axis.domainis no longer supplied a default whenlayout.gridis specified (#1427).- When uploading charts to a plot.ly account via
api_create(), layout attributes are no longer incorrectly src-ified, which was causing inconsistencies in local/remote rendering ofggplotly()charts (#1197).
plotly 4.8.0
NEW FEATURES & IMPROVEMENTS
plotly.js and plot_ly() specific improvements
- Upgraded to plotly.js v1.39.2. A huge amount of features and improvements have been made since v1.29.2 (i.e., the version included in the last CRAN release of the R package - v4.7.1). Highlights include a complete re-write of
scatterglto make it nearly feature complete withscatter, localization of text rendering (i.e., international translations), and six new trace types (cone,scatterpolar,scatterpolargl,splom,table, &violin)! See here for a complete list of plotly.js-specific improvements. - Support for sf (simple feature) data structures was added to
plot_ly(),plot_mapbox(), andplot_geo()(via the newadd_sf()function). See this blog post for an overview. - Better control over the stroke (i.e., outline) appearance of various filled graphical marks via the new "special arguments" (
stroke,strokes,alpha_stroke,span, andspans). For an overview, see the sf blog post linked to in the bullet point above and the new package demos (list all demos withdemo(package = "plotly")).
ggplotly() specific improvements
ggplotly()now supports conversion of ggplot2'sgeom_sf().- One may now inform
ggplotly()about the relevant shiny output size viasession$clientData. This ensuresggplotly()sizing is closer to ggplot2 sizing, even on window resize. For an example, runplotly_example("shiny", "ggplotly_sizing").
Other improvements relevant for all plotly objects
- LaTeX rendering via MathJax is now supported and the new
TeX()function may be used to flag a character vector as LaTeX (#375). Use the newmathjaxargument inconfig()to specify either external (mathjax="cdn") or local (mathjax="local") MathJaX. If"cdn", mathjax is loaded externally (meaning an internet connection is needed for TeX rendering). If"local", the PLOTLY_MATHJAX_PATH environment variable must be set to the location (a local file path) of MathJax. IMPORTANT: plotly uses SVG-based mathjax rendering which doesn't play nicely with HTML-based rendering (e.g., rmarkdown documents and shiny apps). To leverage both types of rendering, you must<iframe>your plotly graph(s) into the larger document (see here for an rmarkdown example and here for a shiny example). - The selection (i.e., linked-brushing) mode can now switch from 'transient' to 'persistent' by holding the 'shift' key. It's still possible to force persistent selection by setting
persistent = TRUEinhighlight(), butpersistent = FALSE(the default) is now recommended since it allows one to switch between persistent/transient selection in the browser, rather than at the command line. - The
highlight()function gains adebounceargument for throttling the rate at whichonevents may be fired. This is mainly useful for improving user experience whenhighlight(on = "plotly_hover")and mousing over relevant markers at a rapid rate (#1277) - The new
partial_bundle()function makes it easy to leverage partial bundles of plotly.js for reduced file sizes and faster render times. - The
config()function gains alocaleargument for easily changing localization defaults (#1270). This makes it possible localize date axes, and in some cases, modebar buttons (#1270). - The
plot_geo()function gains aofflineargument for rendering"scattergeo"traces with or without an internet connection (#356). Leveraging this argument requires the new plotlyGeoAssets package. - Support for async rendering of inside shiny apps using the promises package (#1209). For an example, run
plotly_example("shiny", "async"). - Instead of an error,
ggplotly(NULL, "message")andplotly_build(NULL, "message")now returnshtmltools::div("message"), making it easier to relay messages in shiny when data isn't yet ready to plot (#1116). - The
animation_button()function gains alabelargument, making it easier to control the label of an animation button generated through theframeAPI (#1205). - The new
highlight_key()function provides a wrapper aroundcrosstalk::SharedData$new(), making it easier to teach others how to leverageSharedDataobjects with plotly and crosstalk.
CHANGES
plot_ly() specific changes
- The
nameattribute is now a "specialplot_ly()argument" and behaves similar tosplit(it ensures a different trace for every unique value supplied). Although this leads to a breaking change (namewas 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 thenameattributes (e.g.plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~factor(vs), name = "a")should becomeplot_ly(mtcars, x = ~wt, y = ~mpg, color = ~factor(vs), name = ~paste(vs, "\na"))) - The
colorargument now maps tofillcolor, making it much easier to use polygon fills to encode data values (e.g., choropleth maps). For backwards-compatibilty reasons, whencolormaps tofillcolor,alphadefaults to 0.5 (instead of 1). For an example,plot_mapbox(mn_res, color = ~INDRESNAME)orplot_mapbox(mn_res, split = ~INDRESNAME, color = ~AREA, showlegend = FALSE, stroke = I("black")). - The
colorargument no longer automatically add"markers"to themodeattribute for scatter/scattergl trace types. Those who wish to have the old behavior back, should add"markers"to themodeexplicity (e.g., changeplot_ly(economics, x = ~pce, y = ~pop, color = ~as.numeric(date), mode = "lines")toplot_ly(economics, x = ~pce, y = ~pop, color = ~as.numeric(date), mode = "lines+markers")). - The
sizeargument now informs a default error_[x/y].width (andspaninforms error_[x/y].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))). layout.showlegendnow defaults toTRUEfor a single pie trace. This is a more sensible default and matches pure plotly.js behavior.
Other changes relevant for all plotly objects
- All axis objects now default to
automargin = TRUE. The majority of the time this should make axis labels more readable, but may have un-intended consequences in some rare cases (#1252). - The
elementIdfield is no longer populated, which fixes the "Ignoring explicitly provided widget ID" warning in shiny applications (#985).
BUG FIXES
ggplotly() specific fixes
- The default
height/widththatggplotly()assumes is now more consistently correct in various context, but it also now requires access to one of the following devices:Cairo::Cairo(),png(), orjpg(). - In RStudio,
ggplotly()was ignoring a specifiedheight/width(#1190). ggplotly()now uses fixed heights for facet strips meaning that their height is still correct after a window resize (#1265).
plot_ly() specific fixes
- The
limitsargument ofcolorbar()wasn't being applied toline.color/line.cmin/line.cmax(#1236). - The
legendgroupcan now properly map data values (#1148).
Other fixes relevant for all plotly objects
- Marker sizes (i.e.,
marker.size) are now always based on the area whenmarker.sizemode='area'(which is the default sizemode when using thesizeargument). Previously, traces with one just one value supplied tomarker.sizewere being sized by their diameter (#1133). - Bug fix for linking views with crosstalk where the source of the selection is an aggregated trace (#1218).
- Resizing behavior, after updating
height/widthvia shiny reactive values, is now correct (#1068). - Fixed algorithm for coercing the proposed layout to the plot schema (#1156).
add_*()no longer inheritscrosstalk::SharedDatakey information wheninherit = FALSE(#1242).
CRAN version 4.5.6
CRAN version 4.5.2
3.6.1
3.6.0
New Features & Changes
- Many improvements to the
subplot()function- ggplot2 objects are now officially supported (#520).
- Several new arguments allow one to synchronize x/y axes (#298), height/width (#376), hide/show x/y axis titles.
- A list of plots can now be passed to the first argument.
- A new vignette with examples and more explanation can be accessed via
vignette("subplot").
ggplotly()is now a generic function with a method forggmatrixobjects.plotly_build()is now a generic function.
Bug Fix
- Column facet strips will no longer be drawn when there is only one column.