Search code examples
rr-markdownrstudior-plotly

Greyed out and non interactive preview of plotly in r-markdown in RStudio


Yesterday I updated RStudio and R, and since then most of my markdowns cannot show interactive plots of plotly anymore. Instead I get a greyed out plot (which shows the correct plot, but it is grey and non interactive)

The same markdown works still perfectly on my other PC with the old R and RStudio.

I figured out that any kind of console output (see "Not Working I") supresses the interaction. Also if I plot multiple plots in the same chunk, it also becomes grey and non-interactive (see "Not Working II"). If I just have one plot and I set it up so that no console message is shown, I still get an interactive plot.

Any idea what the issue could be?

EDIT: Also if I knit I get "perfect" plots (interactive and not grey)

Here is a minimum working example which shows the problem:

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(plotly)
```  

```{r Not Working I}  
plot_ly(economics, x = ~date, y = ~unemploy / pop)
```

```{r Working I}
plot_ly(economics, x = ~date, y = ~unemploy / pop, 
             type = "scatter", mode="markers")
```

```{r Not Working II}
plot_ly(economics, x = ~date, y = ~unemploy / pop, 
             type = "scatter", mode="markers")

plot_ly(economics, x = ~date, y = ~unemploy / pop, 
             type = "scatter", mode="markers")
```

Solution

  • It reportedly was a bug which was already fixed with the current daily: https://dailies.rstudio.com/

    The fix will also be backported into the current release.