Subplots with Plots/pyplot()/Juno

Hello,

I am trying to get subplots to work with Plots.jl and pyplot backend. My workflow is as follows:

function my_plot()
    ...
    scatter(...)
end
using Plots
pyplot()
p1 = my_plot(args1);
p2 = my_plot(args2);
plot(p1, p2, layout=(1, 2))

Note that lines that generate p1 and p2 end with semicolons. The plots pane in Atom is turned off.

When i run the entire snippet in Atom (using Ctrl-Shift-Enter), my plot with subplots shows up for a second, and is then replaced with p2. The same thing happens when I run last three lines from the snippet above (Ctrl-Enter). When I run the script from the command line (julia script_file.jl) nothing shows up at all, the script just exits. The only way to get the correct plot (with two subplots) is to run the whole thing from Atom, close the figure window with the wrong plot, and then run just the single last line from the snippet.

Is this a bug in Plots.jl, and does anyone know of a workaround?

My matplotplibrc:

interactive  : False
backend      : TkAgg
julia> versioninfo()
Julia Version 1.0.3
Platform Info:
  OS: Linux (x86_64-conda_cos6-linux-gnu)
...
  [91a5bcdd] Plots v0.23.2
  [438e738f] PyCall v1.91.1
  [d330b81b] PyPlot v2.8.0
1 Like

Hello @tanhevg,

I’ve just experienced and SOLVED a similar issue after upgrading to Julia v1.0.4
so thought I should share ;
Know I’m “late to this party” but hopefully still HTH.

ISSUE KWS: Julia v1.0 Plots.plot MUST RUN AT the Julia REPL
using PyPlot using Plots pyplot()


Configuration Version Info:
julia> versioninfo()
Julia Version 1.0.4
Commit 38e9fb7f80 (2019-05-16 03:38 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)

Environment:
JULIA_EDITOR = atom -a


HOWTO TEST for plot Issue Regressions after Julia version upgrade to 1.0 etc. :
julia> display(Plots.plot!(Plots.fakedata(100,5)))
Plot{Plots.PyPlotBackend() n=24}


** SOLUTION **

Issue : Julia plotting-works-ONLY-in-repl CLI ( NOGO Scripts.jl ) From Link here >> https://stackoverflow.com/questions/40834142/julia-plotlyjs-plotting-works-only-in-repl

using PyPlot
using Plots
pyplot()
# NOTE CASE ABOVE And this is at VERY TOP of Julia Program Script !!

enclose the plot() command inside the display() function , like this:

display(Plots.plot(layout = (4) ) )

display(Plots.plot!(subplot=1,
display(Plots.plot!(subplot=1, theta_observation_time, x_original_signal, label=“x_original_signal”, linewidth=2*sf) )