# Plots in VSCode

**URL:** https://discourse.julialang.org/t/plots-in-vscode/61690
**Category:** Tooling
**Tags:** plotting, vscode
**Created:** [May 23, 2021, 6:40pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690 "2021-05-23T18:40:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [May 23, 2021, 6:40pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/1 "2021-05-23T18:40:53Z")

</div>

Hello

I am using the Julia extension in VSCode.  
I am a little confused with how plotting works in it.

I have something like this in a Julia script

```julia
Grid_Size = LinRange(1E0, 1E5, 100)
Log_of_Size = map(log, Grid_Size)
plot(Grid_Size, Log_of_Size)

```

When I do `Julia: Execute File REPL` no plot pane appears. I have to enclose the plot command in `display()` to get the plot pane to appear.

Is this the intended behavior? It seemed more natural to just have to include the line `plot(Grid_Size, Grid_Size, label="Linear Scaling")` for a plot to show up. I’m probably missing something. I’d appreciate any thoughts.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [May 23, 2021, 7:08pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/2 "2021-05-23T19:08:37Z")

</div>

```julia
p = plot(x,y,...) # create the plot object
display(p) # display the plot object

```

tells julia to display the object `p`. IMO this is better than having it implicitly show up on some display without user control.

---

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [May 23, 2021, 7:40pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/3 "2021-05-23T19:40:45Z")

</div>

Thanks - I’ll do that. I’m just confused why just doing `plot()` doesn’t seem to be working in this particular script file. If I create a new file and do

```julia
using Plots

plot(1:1:10, map(x -> x^2, 1:1:10))

```

It appears to work fine (a plot appears in the plot pane).

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [May 23, 2021, 7:46pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/4 "2021-05-23T19:46:14Z")

</div>

The last expression in the file will be displayed automatically.

---

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [May 23, 2021, 7:49pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/5 "2021-05-23T19:49:37Z")

</div>

Doh! Thanks - is that a feature of julia scripts or the VS Code extension?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [May 23, 2021, 7:51pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/6 "2021-05-23T19:51:01Z")

</div>

Both, but I’d say it’s best not to rely on it.

---

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [May 23, 2021, 8:00pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/7 "2021-05-23T20:00:07Z")

</div>

Hm - I just created a file and put the following

```julia
a = 5
b = 6.0
c = a * b

```

I ran it from the terminal and it didn’t output anything. Based on what you said above, it should have returned `30.0` right?

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [May 23, 2021, 9:52pm UTC](https://discourse.julialang.org/t/plots-in-vscode/61690/8 "2021-05-23T21:52:40Z")

</div>

This is true if you include a file within a Julia session (e.g. in the REPL, IJulia…), but not if you run it from the shell. There you have to explicitly show the result, either with `@show`, `println`… or `display` in the case of plots, as already explained.
