# PyPlot 3d plotting

**URL:** <https://discourse.julialang.org/t/pyplot-3d-plotting/30838>\
**Category:** General Usage\
**Created:** [November 7, 2019, 5:05pm UTC](https://discourse.julialang.org/t/pyplot-3d-plotting/30838 "2019-11-07T17:05:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [November 7, 2019, 5:05pm UTC](https://discourse.julialang.org/t/pyplot-3d-plotting/30838/1 "2019-11-07T17:05:37Z")

</div>

Why this code does not work without second line: p1=scatter3D(,0) ? This line is unnecessary for me. How to write it correctly to get one chart, not two ?

```julia
using PyPlot
p1=scatter3D([],0)
fig = plt.figure()
ax = fig.add_subplot(projection="3d")
ax.scatter(rand(100),rand(100),rand(100),color="red")
ax.scatter(rand(100),rand(100),rand(100),color="yellow")
ax.scatter(rand(100),rand(100),rand(100),color="blue")

```

Second question: How to close p1 ?  
Thx

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 7, 2019, 7:02pm UTC](https://discourse.julialang.org/t/pyplot-3d-plotting/30838/2 "2019-11-07T19:02:49Z")

</div>

> [@programista](#):
>
> Why this code does not work without second line: p1=scatter3D(,0) ? This line is unnecessary for me.

See the [PyPlot _3d Plotting_ manual](https://github.com/JuliaPy/PyPlot.jl#3d-plotting): just call `using3D()` to ensure 3d plotting is initialized. (Calling an explicit 3d function like `scatter3D` initializes 3d plotting automatically, but you need to initialize explicitly if you are using 3d via a `projection="3d"` keyword).
