plotly v4.9.2.1

0

Monthly downloads

0th

Percentile

Create Interactive Web Graphics via 'plotly.js'

Create interactive web graphics from 'ggplot2' graphs and/or a custom interface to the (MIT-licensed) JavaScript library 'plotly.js' inspired by the grammar of graphics.

Readme

Build
Status CRAN
Status CRAN
Downloads monthly

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

<http://i.imgur.com/G1rSArP.gifv>

By default, 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 dynamicTicks, which tells plotly.js to dynamically recompute axes, when appropriate. The style() function also comes in handy for modifying the underlying trace 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"))

<http://i.imgur.com/qRvLgea.gifv>

Moreover, since ggplotly() returns a plotly object, you can apply essentially any function from the R package on that object. Some useful ones include layout() (for customizing the layout), add_traces() (and its higher-level add_*() siblings, for example add_polygons(), for adding new traces/data), subplot() (for combining multiple plotly objects), and plotly_json() (for inspecting the underlying JSON sent to plotly.js).

The ggplotly() function will also respect some “unofficial” ggplot2 aesthetics, namely text (for customizing the tooltip), frame (for creating animations), and ids (for ensuring sensible smooth transitions).

Using plotly without ggplot2

The plot_ly() function provides a more direct interface to plotly.js so you can leverage more specialized chart types (e.g., parallel coordinates or maps) or even some visualization that the ggplot2 API won’t ever support (e.g., surface, mesh, trisurf, etc).

plot_ly(z = ~volcano, type = "surface")

<https://plot.ly/~brnvg/1134>

Learn more

To learn more about special features that the plotly R package provides (e.g., client-side linking, shiny integration, editing and generating static images, custom events in JavaScript, and more), see https://plotly-r.com. You may already be familiar with existing plotly documentation (e.g., https://plot.ly/r/), which is essentially a language-agnostic how-to guide for learning plotly.js, whereas https://plotly-r.com is meant to be more wholistic tutorial written by and for the R user. The package itself ships with a number of demos (list them by running demo(package = "plotly")) and shiny/rmarkdown examples (list them by running plotly_example("shiny") or plotly_example("rmd")). Carson also keeps numerous slide decks with useful examples and concepts.

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, asking questions, contributing changes to plotly, and our code of conduct.


<http://ropensci.org>

Functions in plotly

Name Description
as_widget Convert a list to a plotly htmlwidget object
api_create Tools for working with plotly's REST API (v2)
config Set the default configuration for plotly
group2NA Separate groups with missing values
knit_print.api_plot Embed a plotly figure as an iframe in a knitr doc
knit_print.api_grid_local Embed a plotly grid as an iframe in a knitr doc
as.widget Convert a plotly object to an htmlwidget object
embed_notebook Embed a plot as an iframe into a Jupyter Notebook
hide_colorbar Hide color bar(s)
plot_ly Initiate a plotly visualization
get_figure Request a figure object
hide_guides Hide guides (legends and colorbars)
plot_mapbox Initiate a plotly-mapbox object
rangeslider Add a range slider to the x-axis
gg2list Convert a ggplot to a list.
raster2uri Encode a raster object as a data URI
plotly_POST Create/Modify plotly graphs
plot_dendro Plot an interactive dendrogram
plotly_build 'Build' (i.e., evaluate) a plotly object
plot_geo Initiate a plotly-geo object
ggplotly Convert ggplot2 to plotly
plotly_example Run a plotly example(s)
res_mn Minnesotan Indian Reservation Lands
schema Acquire (and optionally display) plotly's plot schema
orca Static image exporting
hide_legend Hide legend
partial_bundle Use a partial bundle of plotly.js
plotly_empty Create a complete empty plotly graph.
attrs_selected Specify attributes of selection traces
plotly_data Obtain data associated with a plotly graph
plotly_json Inspect JSON sent to plotly.js
to_basic Convert a geom to a "basic" geom.
event_unregister Un-register a shiny input value
export Export a plotly graph to a static file
print.api_grid_local Print a plotly grid object
event_register Register a shiny input value
hobbs Hobbs data
event_data Access plotly user input event data in shiny
knit_print.api_grid Embed a plotly grid as an iframe in a knitr doc
print.api_plot Print a plot on plotly's platform
mic Mic data
showRGB View colors already formatted by toRGB()
signup Create a new plotly account.
offline Plotly Offline
print.api_grid Print a plotly grid object
print.api Print method for a 'generic' API response
plotly-shiny Shiny bindings for plotly
style Modify trace(s)
wind Wind data
subplot View multiple plots in a single view
plotly Main interface to plotly
highlight_key Highlight/query data based on primary key
layout Modify the layout of a plotly visualization
last_plot Retrieve the last plot to be modified or created.
plotlyProxy Modify a plotly object inside a shiny app
mutate Objects exported from other packages
highlight Query graphical elements in multiple linked views
plotly_IMAGE Create a static image
remove_typedarray_polyfill Remove TypedArray polyfill
toRGB Convert R colours to RGBA hexadecimal colour values
toWebGL Convert trace types to WebGL
TeX Render TeX in a plotly graph using MathJax
add_data Add data to a plotly visualization
add_annotations Add an annotation(s) to a plot
geom2trace Convert a "basic" geoms to a plotly.js trace.
add_fun Apply function to plot, without modifying data
add_trace Add trace(s) to a plotly visualization
animation_opts Animation configuration options
bbox Estimate bounding box of a rotated string
colorbar Modify the colorbar
No Results!

Last month downloads

Details

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/plotly)](http://www.rdocumentation.org/packages/plotly)