# Using Plots, is there a simple way to plot a 3D cube/rectangle?

**URL:** https://discourse.julialang.org/t/using-plots-is-there-a-simple-way-to-plot-a-3d-cube-rectangle/94528
**Category:** General Usage
**Tags:** plots, plotlyjs
**Created:** [February 12, 2023, 6:47pm UTC](https://discourse.julialang.org/t/using-plots-is-there-a-simple-way-to-plot-a-3d-cube-rectangle/94528 "2023-02-12T18:47:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [February 12, 2023, 6:47pm UTC](https://discourse.julialang.org/t/using-plots-is-there-a-simple-way-to-plot-a-3d-cube-rectangle/94528/1 "2023-02-12T18:47:59Z")

</div>

Hello!

I found this nice function online:

```julia
rectangle(w, h, x, y) = Shape(x .+ [0,w,w,0], y .+ [0,0,h,h])

```

Which can produce:

```julia
x = y = 1
w = h = 1

plot(rectangle(w, h, x, y))

```

![image](https://global.discourse-cdn.com/julialang/original/3X/4/5/452afe2f266367d59dc1c9366ef4931000564114.png)

Does anyone know how to produce a 3d equivivalent ? 🙂

Kind regards

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [February 12, 2023, 6:49pm UTC](https://discourse.julialang.org/t/using-plots-is-there-a-simple-way-to-plot-a-3d-cube-rectangle/94528/2 "2023-02-12T18:49:19Z")

</div>

I know this answer here:

> [@How to plot a cube in 3D in Plots.jl](https://discourse.julialang.org/t/how-to-plot-a-cube-in-3d-in-plots-jl/86919/2):
>
> You can not plot vertical surfaces using surface, you’d need mesh3d for this: using Plots xp = [0, 0, 0, 0, 1, 1, 1, 1]; yp = [0, 1, 0, 1, 0, 0, 1, 1]; zp = [0, 0, 1, 1, 1, 0, 0, 1]; connections = [(1,2,3), (4,2,3), (4,7,8), (7,5,6), (2,4,7), (1,6,2), (2,7,6), (7,8,5), (4,8,5), (4,5,3), (1,6,3), (6,3,5)]; mesh3d(xp,yp,zp; connections, xlabel="x", proj\_type = :persp, linecolor=:black)

I was wondering if I could do it using Shapes?

Or is this the go to approach?

Kind regards
