I have the following problem while plotting with Plots.jl
. I like to plot the rosenbrock function
rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
as surface, which expects a 2d Tuple{Float64,Float64}
as input.
What I could come up with, is the following:
using Plots
gr()
rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
ts = linspace(-1.0, 1.0, 100)
x = ts
y = map(rosenbrock, [(x, z) for (x,z) in zip(ts,ts)])
z = map(rosenbrock, [(x, y) for (x,y) in zip(ts,ts)])
# plot(x, x, z)
plot(x, y, z, st = [:surface, :contourf])
I think I messed up some dimensions, but I don't see what I got wrong.
Do I have to nest the calculation of the mappings for y
and x
to get the result?