Julia 3D surface plot like Matlab, colormap in log scale

Viewed 1298

I'm trying to plot 3D surface plot like the figure below (source: Wikipedia):

enter image description here

Here is my attempt in julia;

x  = [-2:0.05:2;]
y = [-1:0.05:3;]
z = (1 .-x').^2 .+ 100 .*(y.-x'.^2).^2

minZ = minimum(z[:]);  
maxZ = maximum(z[:]);

c =  minZ .+ (maxZ-minZ).*log.(1 .+z .- minZ) ./ log(1+maxZ-minZ)
Plots.plot(x,y,z,st=:surface,color=cgrad(:jet,c),
xlabel = "x",ylabel="y",zlabel="f(x,y)")

enter image description here

Here are my questions:

  1. How can I get the julia plot color map appear like Matlab, even log scale does not work.
  2. View (camera) for Matlab plot Azimuth and Elevation is (-30,30) while julia plot camera option does not work at all.camera = (-30,30). Negative values does not seem to work in camera option. How can me make the view (x and y option) appear similar to matlab.

For reference Matlab codel:

clear all;
close all;
hfig = figure(1);

s = 0.05;
X = [-2 : s : 2+s];
Y = [-1 : s : 3+s];
[X, Y] = meshgrid(X, Y);
Z = (1-X).^2 + 100*(Y-X.^2).^2;

% Use log scale of Z for a batter usage of the color spectrum  
minZ = min(Z(:));  
maxZ = max(Z(:));
C = minZ + (maxZ-minZ).*log(1+Z-minZ)./log(1+maxZ-minZ); 


colormap(jet);
surf(X, Y, Z, C, 'EdgeColor', 'none', 'LineStyle', 'none');
 
axis([-2, 2, -1, 3, 0, 2500]);
xlabel('x', 'fontsize', 18);
ylabel('y', 'fontsize', 18);
zlabel('f', 'fontsize', 18);

Thank you

1 Answers

Maybe this will be usefull?

pyplot()
Plots.plot(x,y,z,st=:surface,color=Colors.diverging_palette(20,300,40, logscale=true,  wcolor=colorant"red",dcolor1=colorant"green", dcolor2=colorant"red", b=0.1,d1=1.0,d2=1.0),
       xlabel = "x",ylabel="y",zlabel="f(x,y)",camera=(-30,30))

enter image description here

Related