Learn R Programming

Hmisc (version 5.3-0)

plotlySave: Save a Plotly Graphic to PNG

Description

plotlySave saves a plotly graphic with name foo.png where foo is the name of the current chunk. You must have a free plotly account from plot.ly to use this function, and you must have run Sys.setenv(plotly_username="your_plotly_username") and Sys.setenv(plotly_api_key="your_api_key"). The API key can be found in one's profile settings. See http://stackoverflow.com/questions/33959635/exporting-png-files-from-plotly-in-r.

Usage

plotlySave(x, ...)

Value

called for its side effect of writing one or more PNG files; returns invisible(NULL)

Arguments

x

a plotly graphics object or a named list of such objects. The resulting png file will go in the file path given by the knitr fig.path value, and have a base name equal to the current knitr chunk name. If x is a list, a minus sign followed by the chunk name are inserted before .png.

...

additional arguments passed to plotly::plotly_IMAGE

Examples

Run this code
# ```{r chunkname}
# p <- plotly::plot_ly(...)
# plotlySave(p)   # creates fig.path/chunkname.png
# ```

Run the code above in your browser using DataLab