GR plots not shown in own GUI when using Atom

juno
plotting

#1

When using julia v0.7 and plotting using Plots/gr() from Atom, plots refuse to show in the GR gui. If I have plot pane enabled, they show up in the plot pane, when I deselect plot pane, they never show up. In julia 0.6 I had a similar issue which was solved by calling closeall(); gui() after creating a plot, which no longer works on v0.7. Plots from pyplot() show up just fine.

Package status for reference

(v0.7) pkg> st
    Status `~/.julia/environments/v0.7/Project.toml`
  [c52e3926] Atom v0.7.3
  [28b8d3ca] GR v0.32.2
  [e5e0dc1b] Juno v0.5.2
  [b964fa9f] LaTeXStrings v1.0.2
  [3b7a836e] PGFPlots v2.2.2
  [995b91a9] PlotUtils v0.5.2
  [58dd65bb] Plotly v0.1.1
  [91a5bcdd] Plots v0.19.2
  [438e738f] PyCall v1.17.1
  [d330b81b] PyPlot v2.6.0
  [3cdcf5f2] RecipesBase v0.5.0+ [`~/.julia/dev/RecipesBase`]

#2

GR v0.32.3 should work


#3

I just updated and now experience a completely different error, bnoth in atom and in REPL

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0 (2018-08-08 06:46 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> using Plots

julia> gr()
Plots.GRBackend()

julia> plot(randn(10))
ERROR: error compiling _plot!: error compiling _display: could not load library "libGR.so"
libGR.so: cannot open shared object file: No such file or directory
Stacktrace:
 [1] #plot#134(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Array{Float64,1}) at /local/home/fredrikb/.julia/packages/Plots/LWBTU/src/plot.jl:57
 [2] plot(::Array{Float64,1}) at /local/home/fredrikb/.julia/packages/Plots/LWBTU/src/plot.jl:51
 [3] top-level scope at none:0

#4

I have no idea, why this file is (suddenly) missing. Could you please try to rebuild GR:

ENV["GRDIR"]=""
Pkg.build("GR")

This should download the GR run-time libraries (including libGR.so) again.


#5

Thanks! That did the trick :smiley:


#6

Actually, v0.32.3 did not solve the original problem, I still get no plots from atom when using Plots.jl :confused:
Using GR directly gives me plots in the plot pane, even though I have disabled the plot pane

julia> using Plots

julia> gr()
Plots.GRBackend()

julia> plot(randn(10))

julia> gui()


#7

Hmm - works fine for me.


Could you please try this example:

using Plots
gr()
for i in 1:100
  display(histogram(randn(10000)))
end

The plot pane is currently the default target (within Atom). To disable it, the display mechanism in GR has to be changed …


#8

Yes, nothing happens. I have plot-pane disabled and no GUI is shown. The plots are shown just fine if I enable the plot pane, which I do not want to do.


#9

I could change GR’s behaviour if I can obtain the user’s setting for the plot-pane. I’ll check this later …


#10

I’m in the process of redesigning Plots.jl’s and GR’s display system such that it works well with Juno.
Both of those packages don’t really make use of Base’s display system, which is kind of unfortunate.

PR for Plots.jl:

GR should imho follow the same design – push a GRDisplay <: AbstractDisplay to the Base display stack and provide the correct show and display methods. That would probably require a bit of a redesign of GR because e.g. plot() returns nothing instead of something Juno (or the REPL) can call show on.


Short description of how Juno handles plots right now:

  1. We push a JunoDisplay to the top of the display stack.
  2. display(::JunoDisplay, x) catches everything.
  3. If there’s an appropriate show method for x and the plot pane is enabled in the settings we display x in the plot pane (by calling show on it). “Appropriate show method” means most image mime types ( image/svg+xml, image/png, image/jpeg, image/tiff, image/bmp, image/gif) as well as application/juno+plotpane which allows you to use arbitrary HTML.
  4. If there’s no appropriate show method or the plot pane is disabled we don’t do anything and let the rest of the display stack handle displaying the plot. This is where PlotsDisplay (or the hypothetical GRDisplay) comes is relevant.

State of Plotting Packages as of 2018/12/15
#11

This was my idea for GR:

if Main.Atom.PlotPaneEnabled[] == true
    Main.Atom.render(Main.Atom.PlotPane(), content)
    return nothing
else
    return content
end

… but where/how can I disable the PlotPane to test it?


#12

There’s a checkbox in the julia-client settings.

But I don’t really like this solution tbh, because there shouldn’t be any need for you to have any kind of dependency on Atom.jl. If you provide the correct show and display methods everything will just work fine without any package interdependencies.

Edit: My previous post wasn’t quite correct btw – we don’t make sure that JunoDisplay is on the top of the stack in the released version.


#13

Ok - thanks for the info.

I’ll push a short-term solution - but you’re right, I’ll have to improve the show and display methods …


#14

Hello,

I discover today the option “Enable Plot Pane” in julia-client settings, but after unchecking it, I have the same problem as OP (plots never show up with GR backend), three months later :frowning:

(v1.0) pkg> st -m
    [c52e3926] Atom v0.7.10
    [28b8d3ca] GR v0.35.0
    [e5e0dc1b] Juno v0.5.3
    [91a5bcdd] Plots v0.21.0

Amitiés