An interactive graphing library for R
sunburst
, waterfall
, isosurface
.hovertemplate
attribute allows for finer-tuned control over tooltip text. See here for an example.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.Several new features and improvements related to accessing plotly.js events in shiny (learn more about them in this RStudio webinar):
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")
,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
.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")
.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:
orca()
function now supports conversion of much larger figures (#1322) and works without a mapbox api token (#1314).orca_serve()
function was added for efficient exporting of many plotly graphs. For examples, see help(orca_serve)
.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()
.
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).config()
function no longer has a collaborate
argument.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
)subplot()
now works much better with annotations, images, and shapes:
xref
/yref
references an x/y axis these references are bumped accordingly (#1181).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).colorscale
attribute now correctly handles a wider range of input values (#1432, #1485)color
argument in plot_ly()
now uses an evenly spaced grid of values instead of quantiles (#1308).size
argument maps to marker.size
, it now converts to an array of appropriate length (#1479).color
and stroke
arguments now work as expected for trace types with fillcolor
but no fill
attribute (e.g. box
traces) (#1292).event_data()
for heatmaps with atomic vectors for x
/y
/z
is now correct (#1141).marker
objects (#1351).ggplotly()
colorbar would cause issues with hover behavior, which is now fixed (#1381).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).api_create()
, layout attributes are no longer incorrectly src-ified, which was causing inconsistencies in local/remote rendering of ggplotly()
charts (#1197).plot_ly()
specific improvementsscattergl
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.plot_ly()
, plot_mapbox()
, and plot_geo()
(via the new add_sf()
function). See this blog post for an overview.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 improvementsggplotly()
now supports conversion of ggplot2's geom_sf()
.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")
.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).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.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)partial_bundle()
function makes it easy to leverage partial bundles of plotly.js for reduced file sizes and faster render times.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).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.plotly_example("shiny", "async")
.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).animation_button()
function gains a label
argument, making it easier to control the label of an animation button generated through the frame
API (#1205).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.plot_ly()
specific changesname
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"))
)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"))
.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")
).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.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).elementId
field is no longer populated, which fixes the "Ignoring explicitly provided widget ID" warning in shiny applications (#985).ggplotly()
specific fixesheight
/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()
.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 fixeslimits
argument of colorbar()
wasn't being applied to line.color
/line.cmin
/line.cmax
(#1236).legendgroup
can now properly map data values (#1148).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).height
/width
via shiny reactive values, is now correct (#1068).add_*()
no longer inherits crosstalk::SharedData
key information when inherit = FALSE
(#1242).subplot()
function
vignette("subplot")
.ggplotly()
is now a generic function with a method for ggmatrix
objects.plotly_build()
is now a generic function.See NEWS for changes.
gg2list()
now returns an object of class "plotly_built"
instead of "plotly"
to ensure a sensible print method is invoked.
See NEWS for changes.