-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
blank iplot in Jupyter Notebooks #1448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Aha ok I'm not the only one seeing this after all @jonmmease :) I'm also struggling to replicate it reliably though... Any insights you might have @michaelsweeney about how to trigger it would be super helpful in tracking it down. |
yea, the only thing that seems to trigger it is when i'm plotting a lot of high-data-point plots and re-plotting them frequently throughout the day. And once the issue happens it seems to stay for some amount of time, even if I restart my computer, clear cache, restart Notebook, etc. One thing to note is that py.plot does work in this case and I can view the html file of the figure in a separate tab with no problem. Other than that, I haven't really identified any particular moment that causes it, but it does seem to happen at the exact moment that I call over my boss to show him the amazing plot I just made :-) maybe Plotly can smell fear? |
I think your last comment got cut off there :) |
What I've found is that if I "restart and clear output" then the problem persists BUT if I then refresh the page altogether it jolts out of the problematic state. |
interesting, i don't believe that was working for me, i may not have tried literally 'refreshing' the notebook but only closing and reopening in a new instance of chrome. i'll give it a shot next time the problem comes up and report back. |
Thanks for the report and info @michaelsweeney. I haven't been able to reproduce it yet, but here are some working notes: This line is particularly suspicious
The plotly.js bundle is not served from the notebook server as a static resource in the classic notebook. So the requirejs system on the frontend shouldn't be looking there. The plotly.py/plotly/offline/offline.py Lines 268 to 303 in b3dbceb
If I force import plotly
from plotly.offline import iplot
plotly.offline.offline.__PLOTLY_OFFLINE_INITIALIZED = True
...
iplot(data) I get blank space where the plot should be and this JavaScript console error
So in my mind the puzzle here is, what is causing |
@michaelsweeney @nicolaskruchten The next time you get stuck in this state, could you try running the following in the browser JavaScript console and report the output? require(["plotly"], function(Plotly) {console.log(Plotly)}) When things are working correctly I get an output like
Based on the error message above, when in the bad state I'm expecting this to 404. Update 1: Also, please check the value of
in the JavaScript console. When things are working, this should return something like
Update 2: If it turns out that |
Ok, here's what I get during the error: Console Input: Console Output:
Also, confirmed that refreshing the browser works for me. Pretty dumb to not try first before restarting Chrome/Jupyter, but it's good that it at least worked this time. |
Huh, I don't recognize anything in
Was that the end of the output? What do you get when the notebook is in a working state? Could you also look at |
it's working now, and i see the below. and apologies because i'm not very conversant in JS or HTML (dash has been my first attempt at a front-end design) -- how can I look at window.__Plotly?
|
If you open the browser developer tools console, you should be able to type in your own command.
And see what the result is. If things aren't working you may see the result as |
gotcha, thanks. so when it's working, I see:
And when it's not working, I see:
|
update: refreshing browser no longer works as a work-around for me. |
Thanks for the info @michaelsweeney . Do I understand correctly that you have a notebook open that works initially, and then stays open for a while without the browser being refreshed and without the kernel being restarting and then the error behavior begins? @nicolaskruchten could you provide the output of
and
in both the working and non-working states? Thanks! |
yes, that's correct. i'll have the notebook open, nothing is refreshed, and suddenly plots start showing blank and then this 'broken state' continues for some indeterminate amount of time that doesn't seem to respond to any refreshes or restarts. thanks so much for looking into it! |
I don't know if it's important, but do you tend to rerun |
Another question. Are you using |
Hi @michaelsweeney, I added a workaround in #1452 that I'm hoping will make it possible to recover from the error-state by just running If you're able, it would be great if you could you try installing the dev build and giving it a spin.
I expect that you'll hit the same problem as before. But when you do, instead of restarting the kernel or refreshing the browser just run |
great, thanks! and just to check, i should be running 'init_notebook_mode()' and not 'init_notebook_mode(connected=True)'? i'll keep you posted on further developments. appreciate the quick attention!! |
Yes, |
I’ve been using connected=true, in offline mode, per “Generating Offline Graphs within Jupyter Notebook” |
update: the work-around worked. thanks!! |
Thanks for reporting back @michaelsweeney, glad the work around is working for you. I'm going to close this issue for now, but if anyone else experiences this issue and is able to reproduce it please let us know. |
@jonmmease I'm experiencing this issue, but it's not intermittent. I can never get a My Help->About says:
In the Javascript console:
The full URL behind all those |
Hi @kenahoo, if you're working plotly from R then you'll want to check with the R project over at https://github.com/ropensci/plotly. |
Oops, sorry, I was reading a bunch of different threads and apparently I posted on the wrong one! |
I had the same problem with plotly not displaying in a notebook in Kaggle. Due to my use of qgrid, I need to run the notebook, then fresh the browser and then run the notebook again in order for qgrid to properly display the df. I later added an interactive plotly display to the notebook. When I opened the notebook and ran it the plotly display displayed properly but, as usual, the qgrid didn't. I then refreshed the notebook and the qgrid displayed properly but the plotly display didn't. I searched and found this page https://plot.ly/python/renderers/ I then changed the "fig.show()" line in my code to "fig.show(renderer="notebook")" And this fixed my issue. From reading the many good examples of troubleshooting above (all of which surpass my abilities) and then the plotly page above I would guess that the problem arises when the plotly API tries to automatically detect the best renderer to use. And so, when this is manually set to 'notebook' it solves this issue. I hope that this helps and look forward to any feedback. |
Have you added the line: init_notebook_mode(connected = True) |
Please note that as of version 4 which came out in July 2019, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I've locked this issue for now: if anyone encounters rendering issues in the future please check out our troubleshooting guide at https://plotly.com/python/troubleshooting/ and if that doesn't help, please feel free to open a new issue :) |
I've been having a persistent but intermittent issue with iplot in Juypyter notebooks where the plots are blank, but space is taken up in the Jupyter notebook output for them. It seems to happen most often in notebooks with large amounts of data and frequent replotting within the notebook.
it seems like there at least a few other people with the same issue, across multiple versions of both Jupyter Notebooks and Plotly, but I haven't seen a definitive solution or explanation other than restarting computer/notebook, which does not always work in my case.
For what it's worth, in my current Jupyter notebook I'm plotting a simple scatter plot and getting a blank layout:
And here is the JS console output:
The text was updated successfully, but these errors were encountered: