Colormap logscale using Plot

I’m trying to build a 3D surface plot with color in log10 scale. I just want the color to be in the log10 scale NOT the actual values itself.

N = 51
x = range(-10, stop = 10, length = N)
y = x
f(x,y)=x^2+y^2
Plots.plot(x,y,f,st=:surface,color=:jet,camera=(25,65))

See below:

output

Here is the output with Logscale created using GNUPLOT.

Check out the documentation. It is pretty

2 Likes

Thank you. The link really helped.

I have used log scale, but still unable to reproduce the chart from gnuplot.

using Plots
N = 51
x = range(-10, stop = 10, length = N)
y = x
f(x,y)=x^2+y^2
out = Plots.plot(x,y,f,st=:surface,color= cgrad(:jet,scale=log),camera=(25,65))
savefig(out,"out.png")

The key driving factor is z the need to included in cgrad. How would one modify z to get a replica of my original plot.

out

I figured it out:

using Plots
N = 51
x = range(-10, stop = 10, length = N)
y = x
f(x,y)=x^2+y^2
z  = [0.001,0.01,0.05,5,50,100,200]
out = Plots.plot(x,y,f,st=:surface,color= cgrad(:jet,z,scale=log),camera=(25,65))
savefig(out,"out.png")

It would be great if we can automatically estimate values z like gnuplot.

out1

You can do e.g.

z = 10 .^ (1:0.01:2)
2 Likes