Problems with plotting in VSCode

Here is the minimal working example to reproduce the issues. All I am trying to do here is create two plots with two lines each.
image

Firstly, the linter produces warnings for the plot() calls even though the code works just fine. I have no way to get rid of it except to remove linting for calls altogether.

Secondly, if I try to run the entire script using the Julia: Execute File in REPL command, only the final plot shows up in the plot pane. In order for me to get both plots up, I need to run each section individually.

Here is my versioninfo(). I’m jusing the Julia extension on VSCode, v1.3.27. Thanks!

julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, icelake-client)
Environment:
  JULIA_EDITOR = "/home/yenson/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/node"
  JULIA_NUM_THREADS =

You can try it:
display(plot!(randn(5)) in the first plot.

2 Likes

A simple way:

using StatsPlots

serie1=rand(5)
serie2=rand(5)
serie3=rand(10)
serie4=rand(10)

plot(
   plot([serie1 serie2], label=["Serie1" "Serie2"]),
   plot([serie3 serie4], label=["Serie3" "Serie4"]),
   layout=(2,1), size=(800,400), grid=:off 
)

display() should be the right way of doing this (assuming you want two separate plots, one plotted after the other)

I see the same issue with the linter for plot() calls - @pfitzseb is there something in the method signatures of plot that confuses the linter here?

1 Like

Thanks @JaderAzevedo that solved the display problem. Just waiting to hear if anyone knows about the linting issue. Surprised that this isn’t more common considering VSCode is the official editor for Julia now.