# Subplots with Plots/pyplot()/Juno

**URL:** <https://discourse.julialang.org/t/subplots-with-plots-pyplot-juno/22425>\
**Category:** Visualization\
**Tags:** juno\
**Created:** [March 27, 2019, 6:32pm UTC](https://discourse.julialang.org/t/subplots-with-plots-pyplot-juno/22425 "2019-03-27T18:32:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanhevg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tanhevg/32/12025_2.png) [@tanhevg](https://discourse.julialang.org/u/tanhevg)\
**Post date:** [March 27, 2019, 6:32pm UTC](https://discourse.julialang.org/t/subplots-with-plots-pyplot-juno/22425/1 "2019-03-27T18:32:55Z")

</div>

Hello,

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

```julia
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`:

```julia
interactive : False
backend : TkAgg

```

```julia
julia> versioninfo()
Julia Version 1.0.3
Platform Info:
  OS: Linux (x86_64-conda_cos6-linux-gnu)
...

```

```julia
  [91a5bcdd] Plots v0.23.2
  [438e738f] PyCall v1.91.1
  [d330b81b] PyPlot v2.8.0

```

---

<div class="post-metadata">

**Author:** ![Marc.Cox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marc.cox/32/7514_2.png) [@Marc.Cox](https://discourse.julialang.org/u/Marc.Cox)\
**Post date:** [August 22, 2019, 8:26pm UTC](https://discourse.julialang.org/t/subplots-with-plots-pyplot-juno/22425/2 "2019-08-22T20:26:05Z")

</div>

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](https://stackoverflow.com/questions/40834142/julia-plotlyjs-plotting-works-only-in-repl)** CLI ( **NOGO Scripts.jl** ) From Link here \>\> [https://stackoverflow.com/questions/40834142/julia-plotlyjs-](https://stackoverflow.com/questions/40834142/julia-plotlyjs-plotting-works-only-in-repl)[plotting-works-only-in-repl](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) **)**
