# Why the plotCurve3D didn't show up while the code finished running?

**URL:** <https://discourse.julialang.org/t/why-the-plotcurve3d-didnt-show-up-while-the-code-finished-running/125476>\
**Category:** General Usage\
**Created:** [February 2, 2025, 3:45pm UTC](https://discourse.julialang.org/t/why-the-plotcurve3d-didnt-show-up-while-the-code-finished-running/125476 "2025-02-02T15:45:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LarkyJulia](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LarkyJulia](https://discourse.julialang.org/u/LarkyJulia)\
**Post date:** [February 2, 2025, 3:45pm UTC](https://discourse.julialang.org/t/why-the-plotcurve3d-didnt-show-up-while-the-code-finished-running/125476/1 "2025-02-02T15:45:26Z")

</div>

The following code ran and successfully showed “OK2”, but the graph didn’t show up. Why?

```julia
using Plots
using NURBS
using PlotlyJS
using StaticArrays

P0 = SVector(0.0 , 1.0, 0.0)
P1 = SVector(0.25, 1.0, 0.0)
P2 = SVector(0.5 , 1.0, 0.0)
P3 = SVector(0.75, 1.0, 0.0)
P4 = SVector(1.0 , 1.0, 0.0)
control_points = [P0, P1, P2, P3, P4]

degree=3

weights = [1.0, 1.0, 1.0, 1.0, 1.0]

knot_vector = Float64[0, 0, 0, 0, 1, 2, 2, 2, 2]
knot_vector ./= maximum(knot_vector)

println("control_points: ",control_points)

NCurve = NURBScurve(NURB(degree, knot_vector, weights), control_points)

show_points = collect(0:0.1:1.0)
println("show_points: ",show_points)
CNurbs = NCurve(show_points)
println("OK1： ", CNurbs)

plotCurve3D(CNurbs, controlPoints=control_points)
println("OK2")

```

The code finished running, but I see from the vscode problems window, there is a IncorrectCallArgs in plotCurve3D line.

Please help out!

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [February 2, 2025, 4:35pm UTC](https://discourse.julialang.org/t/why-the-plotcurve3d-didnt-show-up-while-the-code-finished-running/125476/2 "2025-02-02T16:35:18Z")

</div>

Your code works for me, both in VS Code and in a standard terminal. Could you check if the issue persists when not using VS Code?

(By the way, if you’re not running this line by line, you should use `display(plotCurve3D(...))`.)

---

<div class="post-metadata">

**Author:** ![LarkyJulia](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LarkyJulia](https://discourse.julialang.org/u/LarkyJulia)\
**Post date:** [February 2, 2025, 10:05pm UTC](https://discourse.julialang.org/t/why-the-plotcurve3d-didnt-show-up-while-the-code-finished-running/125476/3 "2025-02-02T22:05:42Z")

</div>

Thanks, the display() function works in vscode, but I still need add

```julia
sleep(60)

```

then, it showed up for 60 seconds, and close automatically.

Actually, the process will sleep for exactly 60 seconds even if you close the graph window manually.

Why does it behave like this? Shouldn’t it appear automatically and stay visible until I manually close the window?

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [February 3, 2025, 8:36am UTC](https://discourse.julialang.org/t/why-the-plotcurve3d-didnt-show-up-while-the-code-finished-running/125476/4 "2025-02-03T08:36:41Z")

</div>

This all depends on exactly how you run your script. It seems like you’re using something akin to `julia script.jl`. In that case Julia will go through your script and terminate after having executed the last line. Because the plotting window runs asynchronously (in contrast to `sleep`), Julia will open the window, but immediately move on to the next line. When Julia soon after reaches the end of the script and terminates, the plotting window also closes.

If you run your script in interactive mode via `julia -i script.jl`, Julia will not close and you can keep interacting with the plot. Alternatively, you can use `include("script.jl")` into an active REPL. Within VS Code you have _Julia: Execute (Active) File in REPL_.

As a sidenote, I would have expected there to be a `plot(..., block=true)` option, as in Python’s matplotlib, but that doesn’t seem to be the case. This would halt Julia at the plotting code line, so that we don’t reach the end and exit. You could then also use `@spawn`/`@async` `display(plot(..., block=true))` and `wait` at the end of the script to wait there until the window has been closed. But again, no `block` keyword seems to exist. A ‘workaround’ I’ve seen [suggested](https://discourse.julialang.org/t/how-do-i-wait-for-a-plots-jl-window-to-be-closed/80122/2) is to use `readline()` to block the main (IO) thread.

---

<div class="post-metadata">

**Author:** ![LarkyJulia](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LarkyJulia](https://discourse.julialang.org/u/LarkyJulia)\
**Post date:** [February 4, 2025, 3:06am UTC](https://discourse.julialang.org/t/why-the-plotcurve3d-didnt-show-up-while-the-code-finished-running/125476/5 "2025-02-04T03:06:39Z")

</div>

I see, thanks alot!
