I’m running into multiple small issues on this kind of surface plot.
First I’d like to know if I can make it a bit transparent. alpha seems to only affect the colorbar.
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.
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!
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)
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…
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:
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")
The thing is st=:wireframe, as I’ve mentioned, just gives me this:
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!
(...)
p = plot(x,y,f,st=:surface)
plot!(p,xrotation=45,yrotation=45)
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.
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 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.