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] Plots don't render using Plotly in v1.37 ("_display is not defined for this backend") #4583

Closed
niclasmattsson opened this issue Dec 7, 2022 · 8 comments · Fixed by #4584

Comments

@niclasmattsson
Copy link

Using Plotly in version 1.37 returns "_display is not defined for this backend" and no plot is rendered. The same error is reported in old issues like #2407 and #2698, but in those issues the problem was calling plotly() inside a function. That is not the case here. MWE below, which works just fine in Plots 1.36 but not in 1.37.

julia> using Plots

julia> plotly()
┌ Warning: For saving to png with the `Plotly` backend `PlotlyBase` and `PlotlyKaleido` need to be installed.
│   err =
│    ArgumentError: Package PlotlyBase not found in current path.
│    - Run `import Pkg; Pkg.add("PlotlyBase")` to install the PlotlyBase package.
└ @ Plots C:\Users\niclas\.julia\packages\Plots\m8l21\src\backends.jl:508
Plots.PlotlyBackend()

julia> plot(rand(10))  # No plot rendered.
┌ Warning: _display is not defined for this backend.
└ @ Plots C:\Users\niclas\.julia\packages\Plots\m8l21\src\output.jl:216

HOWEVER, there's a weird workaround...

Installing and using PlotlyJS but still running the plotly() backend works in 1.37.

julia> using Plots, PlotlyJS

julia> plotly()
┌ Warning: For saving to png with the `Plotly` backend `PlotlyBase` and `PlotlyKaleido` need to be installed.
│   err =
│    ArgumentError: Package PlotlyBase not found in current path, maybe you meant `import/using .PlotlyBase`.
│    - Otherwise, run `import Pkg; Pkg.add("PlotlyBase")` to install the PlotlyBase package.
└ @ Plots C:\Users\niclas\.julia\packages\Plots\m8l21\src\backends.jl:508
Plots.PlotlyBackend()

julia> Plots.plot(rand(10))   # Works, renders in default web browser.

Backends

This bug occurs on ( insert x below )

(FYI there's no plotly line in the default issue template.)

Backend yes no untested
gr (default) x
plotly x
pyplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version: 1.37
Backend version (]st -m <backend(s)>): not relevant, Plotly built-in
Output of versioninfo():

Julia Version 1.8.2
Commit 36034abf26 (2022-09-29 15:21 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × AMD Ryzen 9 6900HX with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver3)
  Threads: 14 on 16 virtual cores
Environment:
  JULIA_EDITOR = "C:\Users\niclas\AppData\Local\Programs\Microsoft VS Code\Code.exe"
  JULIA_NUM_THREADS = 14
  JULIA_PKG_DEVDIR = C:\Stuff\Julia
@t-bltg
Copy link
Member

t-bltg commented Dec 7, 2022

I know nothing about plotly, but did you install PlotlyBase and PlotlyKaleido as advised ?

The issues you linked are unrelated, since they have been reported for the pyplot backend.

@t-bltg t-bltg added the Plotly label Dec 7, 2022
@niclasmattsson
Copy link
Author

Yes. That went even worse. After installing PlotlyKaleido, running plotly() spawns three kaleiodo.exe processes and never terminates.

@BeastyBlacksmith
Copy link
Member

BeastyBlacksmith commented Dec 7, 2022

Does it work in Plots v1.36 ?

That you get the warning shows, that it doesn't find those packages. However, display should work without these

@BeastyBlacksmith
Copy link
Member

Can confirm this is an regression of 1.37.0:

(@plots1.0) pkg> st Plots
Status `~/.julia/environments/plots1.0/Project.toml`
⌃ [91a5bcdd] Plots v1.36.1
Info Packages marked with ⌃ have new versions available

julia> using Plots; plotly(); plot(rand(10))
┌ Warning: For saving to png with the `Plotly` backend `PlotlyBase` and `PlotlyKaleido` need to be installed.
│   err =
│    ArgumentError: Package PlotlyKaleido not found in current path.
│    - Run `import Pkg; Pkg.add("PlotlyKaleido")` to install the PlotlyKaleido package.
└ @ Plots ~/.julia/packages/Plots/gzYVM/src/backends.jl:420

julia> Wird in einer aktuellen Browsersitzung geöffnet.
(@plots1.0) pkg> st Plots
Status `~/.julia/environments/plots1.0/Project.toml`
  [91a5bcdd] Plots v1.37.0

julia> using Plots; plotly(); plot(rand(10))
[ Info: Precompiling PlotlyBase [a03496cd-edff-5a9b-9e67-9cda94a718b5]
┌ Warning: For saving to png with the `Plotly` backend `PlotlyBase` and `PlotlyKaleido` need to be installed.
│   err =
│    ArgumentError: Package PlotlyKaleido not found in current path.
│    - Run `import Pkg; Pkg.add("PlotlyKaleido")` to install the PlotlyKaleido package.
└ @ Plots ~/.julia/packages/Plots/m8l21/src/backends.jl:508
┌ Warning: _display is not defined for this backend.

@t-bltg
Copy link
Member

t-bltg commented Dec 7, 2022

That you get the warning shows, that it doesn't find those packages. However, display should work without these

I don't understand this: how do you expect the backend to work if the plotly dependencies are not installed ?

@BeastyBlacksmith
Copy link
Member

The javascript part of plotly is installed at installation time via Artifacts

@t-bltg
Copy link
Member

t-bltg commented Dec 7, 2022

What ? Where ? Anyway, most certainly introduced by #4566.

@BeastyBlacksmith
Copy link
Member

Ah I remembered it wrong. You can get a local version in a scratchspace, see #3067.
Either way you still need PlotlyBase, but PlotlyKaleido only for file output.

But its still broken anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants