plotly v4.5.2
Monthly downloads
Create Interactive Web Graphics via 'plotly.js'
Easily translate 'ggplot2' graphs to an interactive web-based version and/or create custom web-based visualizations directly from R. Once uploaded to a 'plotly' account, 'plotly' graphs (and the data behind them) can be viewed and modified in a web browser.
Readme
plotly
An R package for creating interactive web graphics via the open source JavaScript graphing library plotly.js.
Installation
Install from CRAN:
install.packages("plotly")
Or install the latest development version (on GitHub) via devtools:
devtools::install_github("ropensci/plotly")
Getting Started
Web-based ggplot2 graphics
If you use ggplot2, ggplotly()
converts your plots to an interactive, web-based version! It also provides sensible tooltips, which assists decoding of values encoded as visual properties in the plot.
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)
If you'd like to see how ggplotly()
does in converting different ggplot2 examples, we host a plotly version of the official ggplot2 documentation. We also have some of our own examples here.
plotly's custom R interface
plotly.js supports some chart types that ggplot2 doesn't (our cheatsheet provides a nice summary of the available chart types). You can create any of these charts via plot_ly()
.
plot_ly(z = ~volcano, type = "surface")
We have a number of vignettes which explain the plot_ly()
interface in depth as well as numerous examples on the plotly website and bundled with the package.
Capturing plotly events
plotly.js exposes a number of 'standard' events that work consistently across plot types. It's easy to hook into these events using the event_data()
function in shiny apps, as these examples demonstrate:
You can also hook into these events without shiny using htmlwidgets::onRender()
(example). This, however, requires JavaScript knowledge and makes it much harder to coordinate views between htmlwidgets.
Learn more
We have lots of examples on https://plot.ly/r/ and https://plot.ly/ggplot2/, but a more comprehensive review is also available at https://cpsievert.github.io/plotly_book/
Contributing
Please read through our contributing guidelines. Included are directions for opening issues, asking questions, contributing changes to plotly, and our code of conduct.
Functions in plotly
Name | Description | |
colorbar | Modify the colorbar | |
add_data | Add data to a plotly visualization | |
as.widget | Convert a plotly object to an htmlwidget object | |
add_fun | Apply function to plot, without modifying data | |
add_trace | Add trace(s) to a plotly visualization | |
event_data | Access plotly user input event data in shiny | |
geom2trace | Convert a "basic" geoms to a plotly.js trace. | |
get_figure | Request a figure object | |
export | Export a plotly graph to a static file | |
gg2list | Convert a ggplot to a list. | |
ggplotly | Create plotly graphs using ggplot2 syntax | |
hide_legend | Hide legend | |
hobbs | Hobbs data | |
hide_colorbar | Hide color bar(s) | |
hide_guides | Hide guides (legends and colorbars) | |
plot_ly | Initiate a plotly visualization | |
offline | Plotly Offline | |
plot_mapbox | Initiate a plotly-mapbox object | |
layout | Modify the layout of a plotly visualization | |
knit_print.plotly_figure | Embed a plotly figure as an iframe in a knitr doc | |
last_plot | Retrieve the last plot to be modified or created. | |
plotly_build | 'Build' (i.e., evaluate) a plotly object | |
plotly_data | Obtain data associated with a plotly graph | |
mic | Mic data | |
plot_geo | Initiate a plotly-geo object | |
plotly_empty | Create a complete empty plotly graph. | |
plotly_IMAGE | Create/Modify plotly images | |
rangeslider | Add a range slider to the x-axis | |
print.plotly_figure | Print a plotly figure object | |
mutate | Objects exported from other packages | |
schema | Display plotly's plot schema | |
plotly-shiny | Shiny bindings for plotly | |
signup | Create a new plotly account. | |
plotly | Main interface to plotly | |
style | Modify trace(s) | |
subplot | View multiple plots in a single view | |
to_basic | Convert a geom to a "basic" geom. | |
plotly_json | Inspect JSON sent to plotly.js | |
plotly_POST | Create/Modify plotly graphs | |
toRGB | Convert R colours to RGBA hexadecimal colour values | |
toWebGL | Convert trace types to WebGL | |
wind | Wind data | |
add_annotations | Add an annotation(s) to a plot | |
bbox | Estimate bounding box of a rotated string | |
as_widget | Convert a list to a plotly htmlwidget object | |
embed_notebook | Embed a plotly figure as an iframe into a Jupyter Notebook | |
config | Set the default configuration for plotly | |
No Results! |
Last month downloads
Details
License | MIT + file LICENSE |
URL | https://plot.ly/r, https://cpsievert.github.io/plotly_book/, https://github.com/ropensci/plotly |
BugReports | https://github.com/ropensci/plotly/issues |
LazyData | true |
RoxygenNote | 5.0.1 |
imports | base64enc , digest , dplyr , hexbin , htmlwidgets , httr , jsonlite , lazyeval (>= 0.2.0) , magrittr , purrr , scales , tibble , tidyr , viridisLite |
suggests | broom , curl , devtools , GGally , ggthemes , htmltools , knitr , listviewer , maps , MASS , RColorBrewer , rmarkdown , RSclient , Rserve , shiny (>= 0.14) , testthat , webshot |
depends | ggplot2 (>= 2.1.0) , R (>= 3.2.0) |
Contributors | Karthik Ram, Scott Chamberlain, Toby Dylan Hocking, Chris Parmer, Marianne Corvellec, Pedro Despouy |
Include our badge in your README
[](http://www.rdocumentation.org/packages/plotly)