Skip to content

Releases: plotly/plotly.R

plotly 4.9.0

10 Apr 19:47
Compare
Choose a tag to compare

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).

plotly 4.8.0

26 Jul 16:42
Compare
Choose a tag to compare

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 scattergl to make it nearly feature complete with scatter, 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(), and plot_geo() (via the new add_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, and spans). For an overview, see the sf blog post linked to in the bullet point above and the new package demos (list all demos with demo(package = "plotly")).

ggplotly() specific improvements

  • ggplotly() now supports conversion of ggplot2's geom_sf().
  • One may now inform ggplotly() about the relevant shiny output size via session$clientData. This ensures ggplotly() sizing is closer to ggplot2 sizing, even on window resize. For an example, run plotly_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 new mathjax argument in config() 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 = TRUE in highlight(), but persistent = 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 a debounce argument for throttling the rate at which on events may be fired. This is mainly useful for improving user experience when highlight(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 a locale argument 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 a offline argument 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") and plotly_build(NULL, "message") now returns htmltools::div("message"), making it easier to relay messages in shiny when data isn't yet ready to plot (#1116).
  • The animation_button() function gains a label argument, making it easier to control the label of an animation button generated through the frame API (#1205).
  • The new highlight_key() function provides a wrapper around crosstalk::SharedData$new(), making it easier to teach others how to leverage SharedData objects with plotly and crosstalk.

CHANGES

plot_ly() specific changes

  • 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")))
  • 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")).
  • 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")).
  • The size argument now informs a default error_[x/y].width (and span informs 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.showlegend now defaults to TRUE for 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 elementId field 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/width that ggplotly() assumes is now more consistently correct in various context, but it also now requires access to one of the following devices: Cairo::Cairo(), png(), or jpg().
  • In RStudio, ggplotly() was ignoring a specified height/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 limits argument of colorbar() wasn't being applied to line.color/line.cmin/line.cmax (#1236).
  • The legendgroup can 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 when marker.sizemode='area' (which is the default sizemode when using the size argument). Previously, traces with one just one value supplied to marker.size were 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/width via shiny reactive values, is now correct (#1068).
  • Fixed algorithm for coercing the proposed layout to the plot schema (#1156).
  • add_*() no longer inherits crosstalk::SharedData key information when inherit = FALSE (#1242).

CRAN version 4.5.6

17 Nov 15:48
Compare
Choose a tag to compare

CRAN version 4.5.2

3.6.1

18 May 04:02
Compare
Choose a tag to compare

Summary of Changes

3.6.0

18 May 02:26
Compare
Choose a tag to compare

New Features & Changes

  • Many improvements to the subplot() function
    1. ggplot2 objects are now officially supported (#520).
    2. Several new arguments allow one to synchronize x/y axes (#298), height/width (#376), hide/show x/y axis titles.
    3. A list of plots can now be passed to the first argument.
    4. A new vignette with examples and more explanation can be accessed via vignette("subplot").
  • ggplotly() is now a generic function with a method for ggmatrix objects.
  • plotly_build() is now a generic function.

Bug Fix

  • Column facet strips will no longer be drawn when there is only one column.

3.5.5

11 May 19:11
Compare
Choose a tag to compare

Summary of Changes

ggplotly() will now use plotly's layout.axisid.title (instead of layout.annotations) for axis titles on non-faceted plots. This will make for a better title placement experience (see #510).

Bug Fix

Space for interior facet_wrap() strips are now accounted for.

3.5.4

05 May 01:55
Compare
Choose a tag to compare

See NEWS for changes.

Summary of Changes

gg2list() now returns an object of class "plotly_built" instead of "plotly" to ensure a sensible print method is invoked.

3.5.3

04 May 17:39
Compare
Choose a tag to compare

See NEWS for changes.

Summary of changes

Upgrade to plotlyjs v1.10.1

3.5.2

04 May 17:39
Compare
Choose a tag to compare

See NEWS for changes.