- Plotly R figures appear interactively within RStudio's graphics viewer without any calls to Plotly's server by default. This means that all plots generated in RStudio are offline. You will have to make a
api_createcall in order to upload your plot onto the Chart Studio Cloud.
- When you're ready to share, you can publish your Plotly R figures to the Chart Studio Cloud or to your company's internal Chart Studio Enterprise server.
To get started with Plotly offline in RStudio, download Plotly's free R client.
Getting the HTML for a Plotly Graph
You could treat the viewer in RStudio as an embedded web browser. Thus it's possible to view the source of that page. What you have to do is
export button in the viewer, and choose
Save as Web Page.
You will then be prompted to save the web page. Then you will be able to view the source code when viewing the plot.
An alternative method in which to get the html for your plot is to call the following command:
htmlwidgets::saveWidget(as.widget(p), "graph.html"), where p will be your plot figure.
Note that you could name the html file to anything you choose.
Working with Shiny
With Shiny and Plotly you can now make data visualization interactive. What Shiny allows you to do is affect the state of your plots
via widgets provided by the
Shiny package or even custom widgets you write in HTML yourself. What this means is that you can interact
with both the styling of the plots, as well as the data that's being plotted. Thus you can do things like filter date on the fly and have
your plot reflect these changes. To get started, visit: https://plot.ly/r/shiny-tutorial/, and for a collection of examples,