Skip to content

plotly 4.9.0

Compare
Choose a tag to compare
@cpsievert cpsievert released this 10 Apr 19:47
· 304 commits to master since this release

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, use title = 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 for layout.title as well as layout.xaxis.title/layout.yaxis.title/etc.

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 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"),
    • 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.
    • 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").
    • The event_data() function now relays the (official plotly.js) customdata attribute in similar fashion to (unofficial) key attribute (#1423). Run plotly_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 to NULL when clicking on a plot after triggering the "plotly_selected" event (#1121) (#1122).
  • 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, see help(orca_serve).
    • The orca() function gains new arguments more_args and ... for finer control over the underlying system commands.
  • 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 with readRDS()). 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 of plotlyProxyInvoke() 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, see plotly_example("shiny", "event_data_annotation").

  • The plotly_example() function will now attempt to open the source file(s) used to run the example. Set edit = 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 to I(1). This results in a slightly narrower default span for some trace types (e.g., box, contour), but it also ensures the stroke 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 a collaborate argument.
  • The cloud argument is now deprecated and will be removed in a future version. Use showSendToCloud instead.
  • ggplotly() now translates title information to layout.title.text (instead of layout.title) and layout.title.font (instead of layout.titlefont)

BUG FIXES

  • subplot() now works much better with annotations, images, and shapes:
    • When xref/yref references an x/y axis these references are bumped accordingly (#1181).
    • When xref/yref references paper coordinates, these coordinates are updated accordingly (#1332).
  • 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 in plot_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 to marker.size, it now converts to an array of appropriate length (#1479).
  • The color and stroke arguments now work as expected for trace types with fillcolor but no fill attribute (e.g. box traces) (#1292).
  • Information emitted by in event_data() for heatmaps with atomic vectors for x/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 when hoveron='fills+points' (#1448).
  • layout.[x-y]axis.domain is no longer supplied a default when layout.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 of ggplotly() charts (#1197).