Plots.jl: Can't display multiple plots (errors with `plotlyjs()`)

Created on 5 Sep 2018  路  5Comments  路  Source: JuliaPlots/Plots.jl

Hi! First off, I wanted to say thanks for Plots.jl :) It's been a joy to use and I've particularly enjoyed RecipesBase.jl. However, I am running into some errors when I try plotting multiple instances.

Ideal behaviour

This works when I use PlotlyJS directly.

using PlotlyJS
x=1:10; plot(x)
plot(x)

I get two separate windows, each displaying a plot. In my use-case, this is ideal, as I'm typically viewing multiple plots at a time when analysing data. If there's a better way, I'm happy to hear it :)

Behaviour with Plots and pyplot() as the backend

using Plots
pyplot()
x=1:10; plot(x)
plot(x)

Only one window is ever displayed.

Behaviour with Plots and plotlyjs() as the backend

using Plots
plotlyjs()
x = 1:10
plot(x)
plot(x)

ERROR: type SyncPlot has no field view
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18
 [2] _create_backend_figure(::Plots.Plot{Plots.PlotlyJSBackend}) at /home/kyle/.julia/packages/Plots/AYsQt/src/backends/plotlyjs.jl:15
 [3] #invokelatest#1 at ./essentials.jl:686 [inlined]
 [4] invokelatest at ./essentials.jl:685 [inlined]
 [5] _plot_setup(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}) at /home/kyle/.julia/packages/Plots/AYsQt/src/pipeline.jl:215
 [6] _plot!(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Tuple{UnitRange{Int64}}) at ./logging.jl:313
 [7] #plot#132(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::UnitRange{Int64}) at /home/kyle/.julia/packages/Plots/AYsQt/src/plot.jl:57
 [8] plot(::UnitRange{Int64}) at /home/kyle/.julia/packages/Plots/AYsQt/src/plot.jl:51
 [9] top-level scope at none:0

Bug?

Extra info

julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
PlotlyJS

Most helpful comment

Pass reuse = false to the second plot to open it in a new window. You can also do p = plot(x); p2 = plot(y); plot(p1, p2) to have the plots open as separate panels in the same window.

The syncplot thing indeed looks like a bug.

All 5 comments

Pass reuse = false to the second plot to open it in a new window. You can also do p = plot(x); p2 = plot(y); plot(p1, p2) to have the plots open as separate panels in the same window.

The syncplot thing indeed looks like a bug.

Bug?

The plotlyjs backend for Plots has not been updated for julia 1.0 yet. I have a local fix, but this requires https://github.com/JuliaLang/METADATA.jl/pull/17541. I will submit a PR in the coming days.

Some more googling and I also found that Plots.default(overwrite_figure=false) works for pyplot(). With plotlyjs() though, I get the following:

image

New windows pop up but no data. At any rate, I will check back here after your PR gets in! Thanks for the prompt response :)

Using Plots.jl from the julia REPL works only for the first expression: plot(rand(100))

julia> versioninfo()
Julia Version 0.7.0
Commit a4cb80f3ed (2018-08-08 06:46 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
  JULIA_BINDIR = /home/opt/julia/julia-0.7.0/bin
  JULIA_NUM_THREADS = 4

julia> using Plots

julia> plotlyjs()
Plots.PlotlyJSBackend()

julia> plot(rand(100))

julia> plot(rand(100,2))
ERROR: type SyncPlot has no field view
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18
 [2] _create_backend_figure(::Plots.Plot{Plots.PlotlyJSBackend}) at /home/sebastian/.julia/packages/Plots/ex9On/src/backends/plotlyjs.jl:15
 [3] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [4] invokelatest at ./essentials.jl:690 [inlined]
 [5] _plot_setup(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}) at /home/sebastian/.julia/packages/Plots/ex9On/src/pipeline.jl:215
 [6] _plot!(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Float64,2}}) at ./logging.jl:313
 [7] #plot#136(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Array{Float64,2}) at /home/sebastian/.julia/packages/Plots/ex9On/src/plot.jl:57
 [8] plot(::Array{Float64,2}) at /home/sebastian/.julia/packages/Plots/ex9On/src/plot.jl:51
 [9] top-level scope at none:0

julia> plot(rand(100), rand(100))
ERROR: type SyncPlot has no field view
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18
 [2] _create_backend_figure(::Plots.Plot{Plots.PlotlyJSBackend}) at /home/sebastian/.julia/packages/Plots/ex9On/src/backends/plotlyjs.jl:15
 [3] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [4] invokelatest at ./essentials.jl:690 [inlined]
 [5] _plot_setup(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}) at /home/sebastian/.julia/packages/Plots/ex9On/src/pipeline.jl:215
 [6] _plot!(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Float64,1},Array{Float64,1}}) at ./logging.jl:313
 [7] #plot#136(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at /home/sebastian/.julia/packages/Plots/ex9On/src/plot.jl:57
 [8] plot(::Array{Float64,1}, ::Array{Float64,1}) at /home/sebastian/.julia/packages/Plots/ex9On/src/plot.jl:51
 [9] top-level scope at none:0

Using Plots.jl in the Atom REPL with the JunoLab/atom-julia-client does not work at all:

julia> versioninfo()
Julia Version 0.7.0
Commit a4cb80f3ed (2018-08-08 06:46 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
  JULIA_BINDIR = /home/opt/julia/julia-0.7.0/bin
  JULIA_NUM_THREADS = 2

julia> using Plots

julia> plotlyjs()
Plots.PlotlyJSBackend()

julia> plot(rand(100))
Error showing value of type Plots.Plot{Plots.PlotlyJSBackend}:
ERROR: Please call `using ORCA` to save figures
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] savefig(::PlotlyJS.SyncPlot, ::String) at /home/sebastian/.julia/packages/PlotlyJS/l4HLS/src/PlotlyJS.jl:65
 [3] plotlyjs_save_hack(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Plots.Plot{Plots.PlotlyJSBackend}, ::String) at /home/sebastian/.julia/packages/Plots/ex9On/src/backends/plotlyjs.jl:69
 [4] _show at /home/sebastian/.julia/packages/Plots/ex9On/src/backends/plotlyjs.jl:72 [inlined]
 [5] showjuno(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.PlotlyJSBackend}) at /home/sebastian/.julia/packages/Plots/ex9On/src/output.jl:275
 [6] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.PlotlyJSBackend}) at /home/sebastian/.julia/packages/Plots/ex9On/src/output.jl:203
 [7] __binrepr at ./multimedia.jl:129 [inlined]
 [8] _textrepr at ./multimedia.jl:119 [inlined]
 [9] #stringmime#6 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Base64/src/Base64.jl:38 [inlined]
 [10] (::getfield(Base64, Symbol("#kw##stringmime")))(::NamedTuple{(:context,),Tuple{IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}}}, ::typeof(Base64.stringmime), ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.PlotlyJSBackend}) at ./none:0
 [11] #stringmime#7(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Function, ::String, ::Plots.Plot{Plots.PlotlyJSBackend}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Base64/src/Base64.jl:39
 [12] #stringmime at ./none:0 [inlined]
 [13] displayinplotpane(::Plots.Plot{Plots.PlotlyJSBackend}) at /home/sebastian/.julia/packages/Atom/WSz3k/src/display/showdisplay.jl:35
 [14] display(::Atom.JunoDisplay, ::Plots.Plot{Plots.PlotlyJSBackend}) at /home/sebastian/.julia/packages/Atom/WSz3k/src/display/showdisplay.jl:55
 [15] display(::Plots.Plot{Plots.PlotlyJSBackend}) at ./multimedia.jl:287
 [16] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [17] invokelatest at ./essentials.jl:690 [inlined]
 [18] print_response(::IO, ::Any, ::Any, ::Bool, ::Bool, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:154
 [19] print_response(::REPL.AbstractREPL, ::Any, ::Any, ::Bool, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:139
 [20] (::getfield(REPL, Symbol("#do_respond#40")){Bool,getfield(Atom, Symbol("##164#165")),REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:708
 [21] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [22] invokelatest at ./essentials.jl:690 [inlined]
 [23] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/LineEdit.jl:2261
 [24] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:1029
 [25] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:191
 [26] (::getfield(Base, Symbol("##831#833")){Bool,Bool,Bool,Bool})(::Module) at ./logging.jl:311
 [27] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [28] invokelatest at ./essentials.jl:690 [inlined]
 [29] macro expansion at ./logging.jl:308 [inlined]
 [30] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:340
 [31] exec_options(::Base.JLOptions) at ./client.jl:252
 [32] _start() at ./client.jl:432

julia> using ORCA
Gtk-Message: 22:25:37.584: Failed to load module "canberra-gtk-module"

julia> plot(rand(100))
ERROR: type SyncPlot has no field view
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18
 [2] _create_backend_figure(::Plots.Plot{Plots.PlotlyJSBackend}) at /home/sebastian/.julia/packages/Plots/ex9On/src/backends/plotlyjs.jl:15
 [3] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [4] invokelatest at ./essentials.jl:690 [inlined]
 [5] _plot_setup(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}) at /home/sebastian/.julia/packages/Plots/ex9On/src/pipeline.jl:215
 [6] _plot!(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Float64,1}}) at ./logging.jl:313
 [7] #plot#136(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Array{Float64,1}) at /home/sebastian/.julia/packages/Plots/ex9On/src/plot.jl:57
 [8] plot(::Array{Float64,1}) at /home/sebastian/.julia/packages/Plots/ex9On/src/plot.jl:51
 [9] top-level scope at none:0

Installed packages...

(v0.7) pkg> status
    Status `~/.julia/environments/v0.7/Project.toml`
  [c52e3926] Atom v0.7.6
  [ad839575] Blink v0.8.0
  [336ed68f] CSV v0.3.1
  [aaaa29a8] Clustering v0.12.0
  [944b1d66] CodecZlib v0.5.0
  [8f4d0f93] Conda v1.0.1
  [3a865a2d] CuArrays v0.7.3
  [a93c6f00] DataFrames v0.13.1
  [864edb3b] DataStructures v0.11.1
  [b4f34e82] Distances v0.7.3
  [31c24e10] Distributions v0.16.3
  [587475ba] Flux v0.6.6
  [f6369f11] ForwardDiff v0.9.0
  [c27321d9] Glob v1.2.0
  [7073ff75] IJulia v1.11.1
  [c8e1da08] IterTools v1.0.0
  [e5e0dc1b] Juno v0.5.3
  [b8a86587] NearestNeighbors v0.4.1
  [47be7bcc] ORCA v0.1.0
  [58dd65bb] Plotly v0.1.1
  [f0f68f2c] PlotlyJS v0.10.3+ #master (https://github.com/sglyon/PlotlyJS.jl.git)
  [91a5bcdd] Plots v0.19.3
  [438e738f] PyCall v1.18.4
  [189a3867] Reexport v0.2.0
  [2913bbd2] StatsBase v0.25.0
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Krastanov picture Krastanov  路  3Comments

Cody-G picture Cody-G  路  4Comments

daschw picture daschw  路  3Comments

PallHaraldsson picture PallHaraldsson  路  4Comments

SebastianM-C picture SebastianM-C  路  4Comments