8

I realize this is not exactly a programming question. I am running the following code and then exporting the plot as a web-page (using R Studio 1.0.44 & R 3.3.1 on Windows 10). When I try to open the saved web-page in Firefox 50.1.0, I don't see anything. The web-page opens fine in Chrome. I have had the problem in two different computers. Could you please check if this is a reproducible problem. If you can think of something I may be doing wrong, please let me know.

set.seed(42)
mydata = data.frame(A = rnorm(20), B = rnorm(20), Index = sample(190:400,20)) 
require(plotly)
x = list(title = "A")
y = list(title = "B")     
mydata$interval = cut(mydata$Index,breaks = 20)   
plot_ly(mydata, x = ~A, y = ~B, type = "scatter",
        mode = 'markers', hoverinfo = 'text', colors = colorRampPalette(c("red", "black"),
        space = "rgb")(20),
        color = ~Index, text = ~paste(interval), marker = list(size=14)) %>%
        layout(xaxis = x, yaxis = y) %>%
        colorbar(title = "My Legend")
d.b
  • 32,245
  • 6
  • 36
  • 77
  • Looks fine in both (plus Safari and Opera) for me on macOS. May be a bug in a version of some part of the stack, though, so it's not an easy thing to fix. – alistaire Jan 24 '17 at 04:11
  • You could open the developer console with F12. Are there some errors in the console output? – phil Jan 24 '17 at 06:20
  • I can't reproduce this error on linux, firefox 50.1.0. Do you have add-ons or plugins installed that may be clashing? Try disabling them. Do you have javascript blocked ( about:config javascript.enabled) – dww Jan 26 '17 at 15:17
  • 1
    On my notebook (which has significantly less memory than my desktop) I encountered this problem - Firefox consumed huge amounts of memory (over 2G) and almost crashed. Opening the html file in a second tab got me no output and a message about being out of memory on the dev console ... This seems to be a known, but currently unfixed, issue - see http://stackoverflow.com/questions/41601669/why-are-plotly-rendered-graphs-not-working-on-mozilla/41761319#41761319 – Jonathan von Schroeder Jan 26 '17 at 16:48
  • Slightly off-topic, this code works fine (with no huge memory consumption previously reported) on win10 with FF 51.0.1 (32bit). – r2evans Jan 28 '17 at 16:47
  • What is the size of the output file? – Maximilian Peters Jan 30 '17 at 22:49
  • @MaximilianPeters, 2.26 MB – d.b Jan 30 '17 at 22:51
  • Firefox has some serious problems with bigger files. I had the same problem with plots which had a lot of data, simply showing the source code was enough to crash Firefox. – Maximilian Peters Jan 30 '17 at 22:56
  • Any new on this? I'm opening a ridiculous small Plotly chart in Firefox 51.0.1 and the memory consumption starts growing until the whole computer hangs (4 GB memory though). – Manuel Feb 04 '17 at 20:58
  • 1
    I've made a comment here for more references https://github.com/ropensci/plotly/issues/721 – Manuel Feb 04 '17 at 22:48

2 Answers2

3

There is a related question at: Why are plotly-rendered graphs not working on Mozilla

It is worth mentioning that this problem does not occur only with offline webpages. If you upload your .html file to a gh-pages branch on GitHub for example, you'll also have problems loading the page with Mozilla.

The short answer (so far) is that you have to do the following workaround in order to get things working in Firefox. Add self_contained: false to the YAML header:

---
title: "Your title"
output:
  html_document:
    self_contained: false
---

The credit for this solution goes to cpsievert (https://github.com/ropensci/plotly/issues/721)

Note: When you add self_contained: false you no longer have a standalone HTML file as output (https://rmarkdown.rstudio.com/html_document_format.html - Document Dependencies).

allanvc
  • 1,096
  • 10
  • 23
0

for python use

url = plotly.offline.plot(data,filename='Changes.html',auto_open=False)

subprocess.call([r'C:\Program Files\Mozilla Firefox\firefox.exe','-new-tab', url])

gokulraja
  • 51
  • 7