# Parametric surface plots with Makie

**URL:** <https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [September 4, 2021, 9:01am UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685 "2021-09-04T09:01:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 4, 2021, 9:01am UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685/1 "2021-09-04T09:01:58Z")

</div>

I am a new user of Makie.

How can I make a parametric plot of a surface in 3-dimensions with Makie?

For example, I am looking for something like this: [ParametricPlot3D—Wolfram Language Documentation](https://reference.wolfram.com/language/ref/ParametricPlot3D.html)

Is there a similar functionality in Makie?

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [September 4, 2021, 2:33pm UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685/2 "2021-09-04T14:33:00Z")

</div>

Currently, you can do it as in these examples:

[https://lazarusa.github.io/BeautifulMakie/surfWireLines/](https://lazarusa.github.io/BeautifulMakie/surfWireLines/)

[https://lazarusa.github.io/BeautifulMakie/surfWireLines/surface1Color/](https://lazarusa.github.io/BeautifulMakie/surfWireLines/surface1Color/)

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 4, 2021, 10:42pm UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685/3 "2021-09-04T22:42:18Z")

</div>

Ah so the trick is to pass `x, y, z` as Matrices instead of Vectors?

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 4, 2021, 10:54pm UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685/4 "2021-09-04T22:54:47Z")

</div>

If you convert the coordinates to vectors, it doesn’t work:

```julia
julia> let
           t = 0:0.1:15
           u = -1:0.1:1
           x = [u*sin(t) for t in t, u in u]
           y = [u*cos(t) for t in t, u in u]
           z = [t/4 for t in t, u in u]
           fig, _ = surface(vec(x), vec(y), vec(z), colorrange = (-2,-1.1), highclip = :orangered, lightposition = Vec3f0(0, 0, 0), ambient = Vec3f0(0.65, 0.65, 0.65), backlight = 5f0) # the colorrange must be outside the range of z
           wireframe!(x,y,z, overdraw = false, linewidth = 0.1) # try overdraw = true
           fig
       end
ERROR: Found duplicate x/y coordinates: Dict((0.0, 0.0) => 48, (-0.0, -0.0) => 31, (-0.0, 0.0) => 31, (0.0, -0.0) => 41)

```

I don’t see this discussed in the docs: [surface](http://makie.juliaplots.org/v0.15.2/examples/plotting_functions/surface/index.html).

Can someone explain the logic here?

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [September 6, 2021, 8:32pm UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685/5 "2021-09-06T20:32:17Z")

</div>

Not sure I understand. The example you were copying from is a surface on an irregular grid, so it needs x and y to be matrices. Not sure how you could recreate the image from that example using vectors. If you want a surface on an ordinary rectangular grid then you can pass in x and y as vectors. This is stated in the docs that you linked. Maybe I am missing the point though?

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 7, 2021, 6:37am UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685/6 "2021-09-07T06:37:37Z")

</div>

What does “irregular” mean in this context?

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [September 7, 2021, 7:26pm UTC](https://discourse.julialang.org/t/parametric-surface-plots-with-makie/67685/7 "2021-09-07T19:26:11Z")

</div>

So I’m far from an expert here. But my understanding is that by regular grid they mean that the view from above would be a, rectangle where the vectors of x and y values give you the 2d points on that rectangle and Z is the height. Whereas an irregular grid can take any shape, e.g. you can set the bottom lefts of the 3 matrices X, Y and Z to be in the same location as the top right.
