Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opening a plotly plot in a browser instead of a viewer in rstudio

Tags:

r

rstudio

plotly

I'm looking for a way to render my plot_ly plot directly to a browser in stead of r-studios default viewer. I've searched the plotly documentation but I only see a reference to the default behavior of opening the plot to a browser when running r from a terminal.

Does anyone know how to open to a browser window by default? Maybe a parameter to the plotly layout() option?

like image 911
user1549537 Avatar asked Jun 22 '16 09:06

user1549537


People also ask

How do you show plotly in R?

In general, there are four different approaches you can take in order to display plotly figures: Using the renderers framework in the context of a script or notebook (the main topic of this page) Using Dash in a web app context. By exporting to an HTML file and loading that file in a browser immediately or later.

Can you use plotly in R?

By default, Plotly for R runs locally in your web browser or in the R Studio viewer. Simply printing the Plotly object will render the chart locally in your web browser or in the R Studio viewer. Plotly graphs are interactive.

What library is Plot_ly in R?

plotly is an R package for creating interactive web-based graphs via the open source JavaScript graphing library plotly. js . As of version 2.0 (November 17, 2015), graphs created with the plotly R package are rendered locally through the htmlwidgets framework.

Does plotly work in RMarkdown?

If you are creating R charts in an RMarkdown environment with HTML output (such as RStudio), simply printing a graph you created using the plotly R package in a code chunk will result in an interactive HTML graph in the viewer.


1 Answers

Alright I found a simple solution in the related questions section next to my original question. Sorry I didn't find it before. stackoverflow.com/questions/36868743 . Setting: options(viewer=NULL) in the script disables the viewer and opens my plot in the browser. Not really elegant and how to turn the default viewer back on is still a little mystery.

like image 56
user1549537 Avatar answered Jan 16 '23 23:01

user1549537