Plotly for R is an interactive, browser-based charting library built on the open source JavaScript graphing library, plotly.js. It works entirely locally, through the HTML widgets framework. Plotly graphs are interactive. You can Click-drag to zoom, shift-click to pan, double-click to autoscale all the graphs.
By default, plotly for R runs locally in your web browser or R Studio’s viewer. You can publish your graphs to the web by creating a plotly account.
To embed plotly plots in R Markdown, simply embed the plotly code into markdown file.
Example:
## Plotly with R Markdown ```{r, plotly=TRUE, echo=FALSE, message=FALSE} library(ggplot2) library(plotly) p <- plot_ly(iris, x = Petal.Length, y = Petal.Width, color = Species, mode = "markers") p ```
Sample Output: