Change mesh color in Plots.jl?

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.

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))

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.

Have you figured this out?

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

Any updates on this?

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

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

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/

I get the folowing display:

2 Likes