Hi there, I would like to produce a contour plot of a quadratic function and I found a nice way to do so with PlotlyJS.contour
but I am not able to customize the number of contours. It seems like the documentation gives a clear way to do so but it is not working for me. Can someone help out please?
Q(θ; ω = 2.0) = (ω * θ[1] + θ[2])^2 + θ[1]^2
θ_grid = -3.0:0.01:3.0
objective_values = Array{Float64}(undef, length(θ_grid), length(θ_grid))
for (i, x) in pairs(θ_grid)
for (j, y) in pairs(θ_grid)
objective_values[i, j] = Q([x, y])
end
end
contour_plot = PlotlyJS.plot(PlotlyJS.contour(x = θ_grid, y = θ_grid, z = objective_values, autocontour = false,
contours=attr(
size = 2,
showlabels = true, # show labels on contours
labelfont = attr( # label font properties
size = 12,
color = "white",
)
)
)
)
In particular, my understanding is that by setting autocontour = false
, I can determine the size of the contours inside contours()
through size but chaging this is producing the same graph.
Thanks a lot in advance!