I'm updating the syntax for julia 1.7. I have everything below working for julia 0.x, and below represents all I found for 1.7, but there are still glitches.
Question 1. How do I get the colorbar to match the colors on the torus? (And why is the cmap = "hot" not working?)
Question 2. Aspect "auto" works, but "equal" gives error "Axes3D currently only supports the aspect argument 'auto'", so how do I get axis equal aspect ratio?
using MAT
using PyPlot
using3D()
N = 200;
R = 10.0;
r = 0.3*R;
dx = 2*pi/(N);
y = zeros(N,1);
x = transpose(y) .+ 0.0;
for ix = 2:N; y[ix] = (ix-1)*dx; x[ix] = (ix-1)*dx; end
x = x .- pi;
y = y .- pi;
cosxsqr = cos.(x) .+ 0.0*y;
sinxsqr = sin.(x) .+ 0.0*y;
sinysqr = 0.0*x .+ sin.(y);
cosysqr = 0.0*x .+ cos.(y);
Rrcosxsqr = broadcast(+,r*cosxsqr,R);
rRrcosx = r*Rrcosxsqr[:];
Xsqr = Rrcosxsqr.*cosysqr;
Ysqr = Rrcosxsqr.*sinysqr;
Zsqr = r*sinxsqr;
display("maxZ")
display(maximum(Zsqr[:]))
display("minZ")
display(minimum(Zsqr[:]))
colors1 = (Zsqr.+abs(minimum(Zsqr[:])))./(2*maximum(Zsqr[:]))
display("min-color")
display(minimum(colors1[:]))
display("max-color")
display(maximum(colors1[:]))
colors3 = cat(colors1,colors1,colors1,dims=3)
pmesh = pcolormesh(colors1)
figure(1)
ax = subplot(1,1,1, projection="3d");
surf(Xsqr,Ysqr,Zsqr,facecolors=colors3,vmin=minimum(abs.(Zsqr[:])),vmax=maximum(abs.(Zsqr[:])),cmap="hot") # Q1 how to get correct colorbar
ax.set_aspect("auto") # Q2 how to get aspect equal
colorbar(pmesh)
