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
hovertemplate
attribute allows for finer-tuned control over tooltip text. See here for an example. - Providing a string to
title
is 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.title
as 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
event
argument 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
priority
argument. By settingpriority='event'
, theevent
is treated like a true event: any reactive expression using theevent
becomes 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)customdata
attribute in similar fashion to (unofficial)key
attribute (#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 toNULL
when 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_args
and...
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
method
argument 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 = FALSE
to prevent the source file(s) from opening. -
An informative warning is now thrown if invalid argument names are supplied to
config()
.
CHANGES
- If
stroke
is specified,span
now defaults toI(1)
. This results in a slightly narrower default span for some trace types (e.g.,box
,contour
), but it also ensures thestroke
is 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 acollaborate
argument. - The
cloud
argument is now deprecated and will be removed in a future version. UseshowSendToCloud
instead. 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
/ysizemode
of"pixel"
) correctly (#1494).- The
colorscale
attribute now correctly handles a wider range of input values (#1432, #1485) - The colorscale generated via the
color
argument 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
size
argument maps tomarker.size
, it now converts to an array of appropriate length (#1479). - The
color
andstroke
arguments now work as expected for trace types withfillcolor
but nofill
attribute (e.g.box
traces) (#1292). - Information emitted by in
event_data()
for heatmaps with atomic vectors forx
/y
/z
is now correct (#1141). - Fixed issue where dplyr groups caused a problem in the ordering of data arrays passed to
marker
objects (#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
text
attribute is no longer collapsed to a string whenhoveron='fills+points'
(#1448). layout.[x-y]axis.domain
is no longer supplied a default whenlayout.grid
is 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).