Surface plot issues

I’m running into multiple small issues on this kind of surface plot.

  1. First I’d like to know if I can make it a bit transparent. alpha seems to only affect the colorbar.
  2. I’d like to do 1) so that I can have a wireframe on top of the surface. However, calling wireframe! seems to simply override the surface plot altogether.
  3. Then, there’s this issue with overlapping tick numbers (1.50 from the x axis overlapping with 0.50 from the y axis), which I’m not sure how to fix.

Any help will be deeply appreciated!

surf

using Plots
x = 0.5:0.01:1.50
y = 0.5:0.01:1.50
f(x,y) = abs2(x-y)
p = plot(x,y,f,st=:surface)
1 Like

I can’t really help you much other than to agree that the docs need some improvement on this front. st=:wireframe can give you a wirefame. I think alpha doesn’t work for 3D plots. A small rotation would probably fix the overlapping tick labels, but I can’t remember how to rotate the plot…

Try any of fillalpha, surfacealpha

You can produce a wireframe in Gaston as follows:

using Gaston
x = 0.5:0.01:1.50
y = 0.5:0.01:1.50
f(x,y) = abs2(x-y)
surf(x,y,f,plotstyle="pm3d")  # plot the surface
x2 = 0.5:0.1:1.5
y2 = 0.5:0.1:1.5
surf!(x2,y2,f)  # superimpose the wireframe (default plotstyle)

which produces:
image

The image can be made transparent by setting the fill style “by hand”, since Gaston does not support specifying a fillstyle with surf yet (see page 172 in gnuplot’s manual):

surf(x,y,f,plotstyle="pm3d",gpcom="set style fill transparent solid 0.25")

gives you

image

1 Like

The thing is st=:wireframe, as I’ve mentioned, just gives me this:

fig

using Plots
x = 0.5:0.01:1.50
y = 0.5:0.01:1.50
f(x,y) = abs2(x-y)
p = plot(x,y,f,st=:surface)
plot!(p,x,y,f,st=:wireframe)

And unfortunately no amount of rotation on the plot fixes the tick labels.
Rotating the labels themselves, on the other hand, sort of fixes it. Even if it still looks a bit cluttered, at least they’re not overlapping. Thanks for the tip!

fig2

(...)
p = plot(x,y,f,st=:surface)
plot!(p,xrotation=45,yrotation=45)

fillalpha, just like alpha, only affects the colorbar.

fig3

using Plots
x = 0.5:0.01:1.50
y = 0.5:0.01:1.50
f(x,y) = abs2(x-y)
p = plot(x,y,f,st=:surface,fillalpha=0.3)
plot!(p,xrotation=45,yrotation=45)

As for surfacealpha: Unknown key: surfacealpha.

This is actually pretty close to what I needed! Thanks for the heads up on this package and for the detailed MWE.

However, this is for a bigger project I’m working on, which already uses Plots.jl basically everywhere. Switching backends just for this use case is a no go. Otherwise I’d have to change it everywhere else and I’m not sure that would be the best route.

1 Like

You should be able to do something similar without going to Gaston. Just superimpose two plots on each other: one with color and the other with the wireframe.

I thought I did exactly that in my response to you.

Am I missing something?

Ah ok I overlooked that. Very interesting that it basically doesn’t work. I’m afraid I can’t be much more help.

I find 3D plotting to be an…adventure…in Plots.jl. Try different backends. Usually I find pyplot() to be the most robust, but this time plotlyjs() was the winner. However, its wireframe rendition is unusual.

surface(x,y,f,fillalpha=0.7)
wireframe!(x,y,f)

temp