# Output doesn't show plots

**URL:** <https://discourse.julialang.org/t/output-doesnt-show-plots/111092>\
**Category:** General Usage\
**Tags:** plot\
**Created:** [March 3, 2024, 2:56pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092 "2024-03-03T14:56:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 3, 2024, 2:56pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/1 "2024-03-03T14:56:15Z")

</div>

I followed the documentation:  
[https://docs.juliaplots.org/latest/output/](https://docs.juliaplots.org/latest/output/)

and tried to write show=true and

```julia
using Plots
arr = [1.2, 1.4, 1.5, 1.1]
x = [1, 2, 3, 4]
p = scatter(x, arr)
display(p)

```

But no new window with the plot appears

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 3, 2024, 3:27pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/2 "2024-03-03T15:27:26Z")

</div>

How are you executing this snippet?

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 3, 2024, 3:50pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/3 "2024-03-03T15:50:49Z")

</div>

julia name\_program.jl

---

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [March 3, 2024, 4:00pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/4 "2024-03-03T16:00:36Z")

</div>

Put a `sleep(60)` at the end of the script to allow the Julia REPL time to display the plot before exiting the script.

Or go full interactive, and instead of

```julia
julia name_program.jl

```

execute

```julia
julia
include("name_program.jl")

```

(then when satisfied quit by `exit()` or `Ctrl-D`)

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 3, 2024, 4:54pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/5 "2024-03-03T16:54:35Z")

</div>

Tomorrow I will have my computer under my hands and I will try

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 4, 2024, 4:24am UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/6 "2024-03-04T04:24:36Z")

</div>

> [@jdad](#):
>
> `julia name_program.jl`

Or try

```julia
julia -i script.jl

```

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 4, 2024, 1:45pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/7 "2024-03-04T13:45:15Z")

</div>

> julia  
> include(“name\_program.jl”)

This works, but sometimes it’s buggy and it works just the first time I use it. I need to quit the julia enviroment to show it again

> julia -i script.jl

This works just the first time, as when I quit, it enters julia enviroment and i need to quit it before running the command again

Update: I’m trying to add logarithmic scale on y axis for scatter plot, but the overall experience is too buggy. Now even the label and ticks are gone away. I need to restart it

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 4, 2024, 2:31pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/8 "2024-03-04T14:31:23Z")

</div>

You could try this. In this scenario, the program will wait for you to push enter to quit. Now you can run the program as before. `julia programfile.jl`.

```julia
using Plots
arr = [1.2, 1.4, 1.5, 1.1]
x = [1, 2, 3, 4]
p = scatter(x, arr)
display(p)
println("Press the enter key to quit:")
readline()

```

We do not usually recommend executing a Julia program from the command line like that during development because you will incur latency each time you run it.

It is not clear to me how you are trying to redisplay the plot or replot. It sounds like you may be closing the window that pops up and that you are not using VSCode.

```julia
using Revise, Plots

function makeplot()
    arr = [1.2, 1.4, 1.5, 1.1]
    x = [1, 2, 3, 4]
    p = scatter(x, arr)
    display(p)
    return p
end

p = makeplot()

if !Base.isinteractive()
    println("Press the enter key to quit:")
    readline()
end

```

To redisplay the plot in interactive mode,

```julia-repl
julia> display(p)

```

To replot, try this:

```julia-repl
julia> p = makeplot()

```

There is some function to force a new window in thr default GR backend.

Anothe alternative would be to try Makie.jl

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 4, 2024, 3:56pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/9 "2024-03-04T15:56:46Z")

</div>

I tried the first example of Makie using CairoMakie, with all the different procedures written above, with and without VSC terminal.

```julia

using CairoMakie

f = Figure(backgroundcolor = :tomato)

```

Nothing shows

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [March 4, 2024, 5:07pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/10 "2024-03-04T17:07:35Z")

</div>

Posting the output of:

```julia
versioninfo()

```

is useful many times for diagnostics.

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [March 4, 2024, 5:40pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/11 "2024-03-04T17:40:22Z")

</div>

Returned items in the Julia REPL are automatically passed to the `display` function, which causes plots to show up as separate windows. In order to display a plot in this context, you should pass the plot object (for `Plots.jl`) or the figure (for `Makie.jl`) to `display`.

Makie also allows you to wait till the screen is closed by following this pattern:

```julia
f = Figure(...)
# do things
screen = display(f)
wait(screen)
# do whatever you want after the screen is closed

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 4, 2024, 6:54pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/12 "2024-03-04T18:54:43Z")

</div>

Did you try VSCode with Plots.jl using the integrated REPL?

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 4, 2024, 7:57pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/13 "2024-03-04T19:57:43Z")

</div>

@mkitti I’m trying with the integrated repl, even if i would like to not use it.  
This doesn’t change anything.

@asinghvi17 it doesn’t work, I attach a screen

 ![Screenshot from 2024-03-04 20-54-32](https://global.discourse-cdn.com/julialang/original/3X/f/b/fb18343adac1aedf318554a710a5d091b039309f.png)

this is the version @Dan

```julia
julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, haswell)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

```

Isn’t there a simple command, like python, which plots everything I say the program to plot?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 4, 2024, 8:25pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/14 "2024-03-04T20:25:18Z")

</div>

We have multiple cascading problems at the moment with the execution environment that I’m trying to disentangle.

Potential issues:

1. Julia is exiting immediately after showing the plot. This is what the various `-i`, ,`readline()`, and `wait` commands are trying to solve.

2. There is a problem with Plots.jl or the GR.jl backend

3. There is a problem with Makie.jl or the CairoMakie.jl backend.

The screenshot is helpful. From this I can determine you are not using the integrated REPL. Rather you are using the integrated terminal, starting Julia from there, which will not achieve the desired effect.

To start the REPL integrated with the julia-vscode extension press Alt+J Alt+O as described here:  
[https://www.julia-vscode.org/docs/stable/userguide/keybindings/](https://www.julia-vscode.org/docs/stable/userguide/keybindings/)

You can then select code you want to execute and press Ctrl-Enter.

What we are trying to achieve is something that looks like this screenshot.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/c/2c37c6dbb82360460e05f8285e0736730d0ad30d.png)

I’m an hour from putting together a demonstration video for you. Just to illustrate this.

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 4, 2024, 8:49pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/16 "2024-03-04T20:49:16Z")

</div>

I actually noticed that if I run the code normally, there is an instant when the color tomato is shown.

This is the REPL screenshot:

 ![Screenshot from 2024-03-04 21-48-22](https://global.discourse-cdn.com/julialang/original/3X/7/4/74f0894eef8068101ab25de1f8197c1927b7d881.png)

The only real error is the last one in the terminal. The other ones were me, trying to understand how the REPL works

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [March 4, 2024, 9:12pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/17 "2024-03-04T21:12:17Z")

</div>

If you are really against interactive use, then you may want to just `save` the figure to disk at the end of your script. Then you can open and view the figure externally to Julia.

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 4, 2024, 9:19pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/18 "2024-03-04T21:19:05Z")

</div>

I surely want to save it when time comes, but before doing so i want to check everything is ok.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 4, 2024, 9:59pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/19 "2024-03-04T21:59:56Z")

</div>

In this context, with CairoMakie.jl, the `wait` function does not apply. This is applicable with other Makie.jl backends such as GLMakie.jl.

CairoMakie.jl works by generating an image and saving it. In your current mode, it is saving it to a temporary file.

Here’s a simple script close to what you were originally trying to achieve.

```julia
using CairoMakie

begin
    arr = [1.2, 1.4, 1.5, 1.1]
    x = [1, 2, 3, 4]
    p = scatter(x, arr)
    display(p)
    if !Base.isinteractive()
        println("Please press any key to continue:")
        readline()
    end
end

```

This is meant to work inside and outside of VS Code. I used the `begin` and `end` blocks to make easier to use in VS Code via Ctrl-Enter.

You can also save the figure out using

```julia
save("test.png", p)

```

I get the following plot.

 ![test](https://global.discourse-cdn.com/julialang/original/3X/3/4/34a30381b8a9e7ac2205cc345de01aaf2bfca1de.png)

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 4, 2024, 10:34pm UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/20 "2024-03-04T22:34:14Z")

</div>

I created a short video on plotting via the REPL outside of VSCode using Plots.jl:

[![](https://global.discourse-cdn.com/julialang/original/3X/0/8/08263e91827048b99a0113e9a2fa2f18e9186df5.jpeg "Demo of using Plots.jl in Julia 1.10.2") ](https://www.youtube.com/watch?v=MN5FR7BNxH4)

Here’s a sequel showing the missing plots problem that you encountered.

[![](https://global.discourse-cdn.com/julialang/original/3X/6/7/67c2e0b291c1b34873fdc0bd33d7e8246e8dca0f.jpeg "Where did my plot go in Julia 1.10.2?") ](https://www.youtube.com/watch?v=xY_sdQVC8-4)

I added a 3rd video showing plotting with GLMakie.jl in the Julia REPL and via a script.

[![](https://global.discourse-cdn.com/julialang/original/3X/1/a/1abf940616be874f251432794cafe40c98bcee0a.jpeg "Plotting using GLMakie.jl in Julia 1.10.2") ](https://www.youtube.com/watch?v=YLTV8DmUYt8)

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [March 5, 2024, 12:23am UTC](https://discourse.julialang.org/t/output-doesnt-show-plots/111092/21 "2024-03-05T00:23:54Z")

</div>

ah CairoMakie won’t display since it’s a vector backend - use GLMakie or WGLMakie for this purpose.

[Next page](https://discourse.julialang.org/t/output-doesnt-show-plots/111092.md?page=2)
