Skip to content
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

[BUG] No plot output from Plots with plotly() backend within Jupyter Notebook (>= ver. 7.00) and VS Code's Notebook #4827

Open
ajw-free opened this issue Sep 28, 2023 · 5 comments

Comments

@ajw-free
Copy link

ajw-free commented Sep 28, 2023

[UPDATE 2023-11-09: The problem of plotly() backend not displaying plots within Jupyter Notebook started with the release of Jupyter Notebook version 7.xx (which is installed by IJulia). See my comment further down on 9 November which gives a temporary solution via installation of an older version of Jupyter Notebook, version 6.5.7]

Original Bug report:

The plotly() backend of Plots does not does not display a plot within Jupyter notebook running on Windows [and also confirmed on MAC as reported by @gmantegna].

The bug is present on MS Windows 11/10 running Julia 1.9.3 [and LTS 1.6.7 and 1.10 beta], IJulia 1.24.2 and Plots 1.39.0 [fresh installation].

[Edit: The problem also exists in VS Code's notebook in Windows.]

The following code displays a blank space instead of the plot.

using Plots
plotly()
display(plot(rand(10)))

If I use the gr() backend, the plot output does display in the notebook.

If I use Plots with plotly() from the command line REPL, it does work - a tab on my browser opens and displays the plot.

Oddly, on my Ubuntu Linux 23.04 installation, running the same version of Julia and packages [Edit: I later realised with an older version of Jupyter 6.4.12], the plotly() backend does work in Jupyter Notebook. The problem is however definitely present on Windows and MAC - I have tested on three different Windows PCs with fresh installations (I deleted any previous ".julia" folder].

The problem is similar to an earlier issue that was closed on 4 June 2023.
"Not seeing any output after running plotly() with julia 1.9" JuliaLang/IJulia.jl#1073
and also reported here
#4739

I have also created a bug report (with more details) on the IJulia github page:
JuliaLang/IJulia.jl#1094

@ajw-free ajw-free added the bug label Sep 28, 2023
@ajw-free ajw-free changed the title [BUG] No plot output from Plots with plotly() backend within Jupter Notebook (affecting Windows and Mac) [BUG] No plot output from Plots with plotly() backend within Jupyter Notebook (affecting Windows and Mac) Sep 28, 2023
@Centauria
Copy link

I run into this problem too, and I found that if I wait for enough time since I run some plotting, interrupt the kernel TWICE would make the output appear, and with no errors/warnings.

@ajw-free
Copy link
Author

I run into this problem too, and I found that if I wait for enough time since I run some plotting, interrupt the kernel TWICE would make the output appear, and with no errors/warnings.

I tried yourmethod on my Windows installation, but I could not make the plot output appear. I tried plotting with Plots with plotly() backend; then waited a minute; then clicked on the "interrupt kernal" button twice, and still nothing appeared.

@ajw-free
Copy link
Author

ajw-free commented Sep 29, 2023

Today I tried using VSCode with the Julia extension to create a notebook.
The same problem is present in VSCode's Notebook on Windows and on Linux.
I.e. using Plots with plotly() backend does not produce an output.

I then installed PlotyJS package via: using Pkg; Pkg.add("PlotlyJS").
Using Plots with plotlyjs() backend worked correctly in VSCode's notebook and displayed a plot.
Unfortunately plotlyjs() backend did not work in Jupyter notebook.

One very strange thing that I noticed in VSCode's notebook was that if I first used plotlyjs() backend to create a plot, and then switched backend to plotly(), the plotly() backend started working!
I then tried the same in Jupyter notebook, but both plotlyjs() and plotly() did not display an output.

EDIT: I have now discovered that if I install PlotlyBase as well as Plots, then using Plots with plotly() backend always works in VS Code. PlotlyBase is the "plot-making guts of PlotlyJS.jl". Its installation must somehow change something when Plots is used with plotly() backend (even though one does not explicitly load PlotlyBase). This does not solve the problem within Jupyter Notebook.

I hope that someone can assist in fixing this bug.
Without plotly() and plotlyjs(), I see no way to create interactive plots using Plots within Jupyter Notebook.
(EDIT: I found another way - one can use WGLMakie for interactive plots inside Jupyter Notebook.)

@ajw-free
Copy link
Author

ajw-free commented Oct 16, 2023

The plotly() problem is also present with other versions of Julia on Windows.

I created fresh installations of Julia LTS v1.6.7 and v1.10.0 beta 3, and then installed IJulia and Plots.

On Windows, Plots with plotly() backend shows no output in Jupyter notebook.

In VS Code's notebook, plotly() backend only shows an output if PlotlyBase is also installed (perhaps this is meant to be so).

EDIT I currently think that the plotly() problem in Jupyter may be with the version of conda and/or Jupter Notebook that is installed by IJulia on Windows machines.

I placed a bug report (with more details) on the IJulia github page:
JuliaLang/IJulia.jl#1094

@ajw-free ajw-free changed the title [BUG] No plot output from Plots with plotly() backend within Jupyter Notebook (affecting Windows and Mac) [BUG] No plot output from Plots with plotly() backend within Jupyter Notebook and VS Code's Notebook (affecting Windows and Mac) Oct 19, 2023
@ajw-free
Copy link
Author

ajw-free commented Nov 9, 2023

After further investigation, I have concluded that the problem is related to an incompatibility with the the current version of Jupyter Notebook that is installed by IJulia.

To see which version of Jupyter Notebook one is using:
Selecting Help -> About Jupyter Notebook

Plotly() backend does not work in the current version of Jupyter Notebook being 7.0.6 (or any version from 7.0.0 onwards)

The last version of the notebook that works with plotly() backend is version 6.5.7 (tested 2024-09-14).
Something went wrong between Notebook release 6.5.x and the next release being 7.0.0.

To reproduce the problem on Windows.
Delete (or rename) the ".julia" folder.
Run Julia. It will be a clean start.

Install packages IJulia and Plots:

using Pkg;
Pkg.add("IJulia");
Pkg.add("Plots")

Then at the Julia prompt, execute:
using IJulia
notebook()

It will then ask the question:
Install Jupiter via conda, y/n? [Y]
Answering yes will then install conda (a mini python) and then also jupyter notebook (newest version, being 7.0.6).

The browser tab opens with Jupyters' filemanager. One can then open a notebook.
If one tries to use Plots with plotly() backend, it does not display a plot.

HERE IS A TEMPORARY SOLUTION:

Use conda to install "jupyter 6.x.x" (the last version that works with plotly() backend) as follows:

 using Pkg
 Pkg.add("Conda")
 using Conda
 Conda.add("notebook=6")  

Now you can try to open a new Jupyter notebook (which should be version 6.5.x) and it should work with Plots and plotly() backend.

Note: You can see all available versions of the notebook package via typing at the julia prompt:

 run(`.julia\\conda\\3\\x86_64\\Scripts\\conda search notebook`)

Now that I have finally found the problem and a temporary solution, I hope that someone can make current versions of IJulia+Plots+plotly() work correctly with the current version of Jupyter Notebook.

(The problem may be with Jupyter Notebook or it may have something to do with the html code that is produced from plotly() within the notebook. A saved html file has missing header information which means it cannot be later viewed in a web-browser - see my comment on 14 September 2023 on JuliaLang/IJulia.jl#1094)

@ajw-free ajw-free changed the title [BUG] No plot output from Plots with plotly() backend within Jupyter Notebook and VS Code's Notebook (affecting Windows and Mac) [BUG] No plot output from Plots with plotly() backend within Jupyter Notebook and VS Code's Notebook Nov 12, 2023
@ajw-free ajw-free changed the title [BUG] No plot output from Plots with plotly() backend within Jupyter Notebook and VS Code's Notebook [BUG] No plot output from Plots with plotly() backend within Jupyter Notebook (>= ver. 7.00) and VS Code's Notebook Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants