Install from CRAN:
Or install the latest development version (on GitHub) via devtools:
If you use ggplot2,
converts your static plots to an interactive web-based version!
library(plotly) g <- ggplot(faithful, aes(x = eruptions, y = waiting)) + stat_density_2d(aes(fill = ..level..), geom = "polygon") + xlim(1, 6) + ylim(40, 100) ggplotly(g)
ggplotly() tries to replicate the static ggplot2 version
exactly (before any interaction occurs), but sometimes you need greater
control over the interactive behavior. The
ggplotly() function itself
has some convenient “high-level” arguments, such as
which tells plotly.js to dynamically recompute axes, when appropriate.
style() function also comes in handy for modifying the
attributes (e.g. hoveron) used to generate the plot:
gg <- ggplotly(g, dynamicTicks = "y") style(gg, hoveron = "points", hoverinfo = "x+y+text", hoverlabel = list(bgcolor = "white"))
ggplotly() returns a plotly object, you can apply
essentially any function from the R package on that object. Some useful
layout() (for customizing the
add_traces() (and its higher-level
add_*() siblings, for example
add_polygons(), for adding new
subplot() (for combining multiple plotly
plotly_json() (for inspecting the underlying JSON sent to
ggplotly() function will also respect some “unofficial”
ggplot2 aesthetics, namely
text (for customizing the
frame (for creating
ids (for ensuring sensible smooth transitions).
plot_ly() function provides a more direct interface to plotly.js
so you can leverage more specialized chart types (e.g., parallel
maps) or even some visualization that the
ggplot2 API won’t ever support (e.g., surface,
plot_ly(z = ~volcano, type = "surface")
demo(package = "plotly")) and shiny/rmarkdown examples (list them by running
plotly_example("rmd")). Carson also keeps numerous slide decks with useful examples and concepts.
Please read through our contributing guidelines. Included are directions for opening issues, asking questions, contributing changes to plotly, and our code of conduct.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.