# Change mesh color in Plots.jl?

**URL:** <https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625>\
**Category:** Visualization\
**Tags:** question, mesh, plots\
**Created:** [February 17, 2022, 12:54pm UTC](https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625 "2022-02-17T12:54:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [February 17, 2022, 12:54pm UTC](https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625/1 "2022-02-17T12:54:47Z")

</div>

I am trying to get a hold on Plots.jl capability to plot meshes. The `mesh3d` seems to be the good choice for that.

With the following example, I manage to plot a uniformly colored mesh with the `plotlyjs` backed.

```julia
using Plots;
plotlyjs();

u1 = LinRange(0, 2 * pi, 100) .* ones(100)'
v1 = (LinRange(0, 2 * pi, 100) .* ones(100)')'
u2 = sin.(u1) .* sin.(v1)
nl, nc = size(u1)

mesh3d(vec(u1), vec(v1), vec(u2))

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/d/edf253a67196185ced8baba4e72b6b791ea880cc.png)

However, the `vertexcolor` parameter that should be used to pass a color to each point seems not to work as `mesh3d(vec(u1), vec(v1), vec(u2), c = :red)` expectedly returns a red mesh, but `mesh3d(vec(u1), vec(v1), vec(u2), c = :red, vertexcolor = vec(u2))` too.  
An attempt to provide a 3-column matrix of numbers in (0-255) failed as well `mesh3d(vec(u1), vec(v1), vec(u2), vertexcolor = rand(size(u2,1),3)*255)`

Does somebody have a clued how this should be done ?

* * *

Note : I know I could plot the surface with `surface(LinRange(0, 2 * pi, 100), LinRange(0, 2 * pi, 100),u2)` but it is not the point here because my end goal is to plot a surface with a non rectangular grid, which does not work with `surface`.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [March 6, 2022, 2:54am UTC](https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625/2 "2022-03-06T02:54:28Z")

</div>

Have you figured this out?

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [March 7, 2022, 8:36pm UTC](https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625/3 "2022-03-07T20:36:10Z")

</div>

Nope. My current solution is to use `Makie` for that which is a bit annoying, as all my other plots are done with `Plots`

---

<div class="post-metadata">

**Author:** ![Ian\_L](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ian_l/32/49509_2.png) [@Ian\_L](https://discourse.julialang.org/u/Ian_L)\
**Post date:** [September 22, 2023, 3:18am UTC](https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625/4 "2023-09-22T03:18:06Z")

</div>

Any updates on this?

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [September 22, 2023, 3:41pm UTC](https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625/5 "2023-09-22T15:41:27Z")

</div>

No, and I switched all of my plotting recipes to Makie… so I’m leaving this open for others…

---

<div class="post-metadata">

**Author:** ![morningglory05](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/morningglory05/32/43282_2.png) [@morningglory05](https://discourse.julialang.org/u/morningglory05)\
**Post date:** [October 31, 2024, 5:10pm UTC](https://discourse.julialang.org/t/change-mesh-color-in-plots-jl/76625/6 "2024-10-31T17:10:13Z")

</div>

I know it is over two years later, but in case someone needs it, here is a solution I got to work with Julia 1.10

```julia
using Plots;
plotlyjs();
u1 = LinRange(0, 2 * pi, 100) .* ones(100)'
v1 = (LinRange(0, 2 * pi, 100) .* ones(100)')'
u2 = sin.(u1) .* sin.(v1)
nl, nc = size(u1)

mesh3d(vec(u1), vec(v1), vec(u2), intensity = vec(u2), color=:buda, showscale=true)

```

Where the colorscale is pulled from: [https://docs.juliaplots.org/latest/generated/colorschemes/](https://docs.juliaplots.org/latest/generated/colorschemes/)

I get the folowing display:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/a/0a0b5acffc700affb8cd792bbb5cc9252ad1d8d1.png)
