Problem plotting surfaces

Hello, there! I’m plotting a surface with the following code:

using Plots

θ = 1.5
K = J/θ

#3D plot
y=range(-2,stop=2)
θ=range(0.1,stop=2)
function f(y,θ)
    J = 1.0
    h = 0.0
    -θ*log(2.0) -θ*log(exp(-(J/θ)*y^2/2)*cosh((J/θ)*y+h))
end
plotlyjs()
p1=plot(y,θ,f,st=:surface,zlabel="f",ylabel="θ",xlabel="y",c=:blues)

The result is

I’m defining \theta \in (0.1,2.0), but the plot stops at \theta = 1.0. Can someone tell what is wrong?

julia> range(0.1,stop=2)
0.1:1.0:1.1

2 Likes

As @rafael.guerra showed, the issue is with the range function. You’re probably better off using the nice : notation for ranges. Maybe try with

y = -2:0.1:2
θ = 0.1:0.1:2
2 Likes