Bumping up since the title is the same I wanted. Tried something similar to what @sschelm suggested. I am using Julia 1.1 and Plots 0.26.2. Full working example is below. Works fine without contour_labels = true
and used to work with ‘clabels = true’ but now it doesn’t.
Any ideas on how to get that sorted?
using Plots, LaTeXStrings
pyplot()
n = 500
x1 = range(-1, stop=10, length=n);
x2 = range(-1, stop=10, length=n);
f(x) = (x[1])^2 + (x[2])^2
z = [f([x1[i], x2[j]]) for j = 1:n, i = 1:n];
contour(x1,x2,z,
levels = [4, 8, 12, 16],
xaxis = (L"$x_1$", (0,4), (0:1:10)),
yaxis = (L"$x_2$", (0,4)),
clims = (1,15),
contour_labels = true,
aspect_ratio = :equal
)
I get an error that looks like this:
MethodError: no method matching getindex(::Base.Generator{Tuple{Int64,Int64},getfield(Plots, Symbol(“##280#282”)){Float64}}, ::Int64)
(::getfield(Plots, Symbol(“##279#281”)){Base.Generator{Tuple{Int64,Int64},getfield(Plots, Symbol(“##280#282”)){Float64}},Array{Int64,1}})(::Int64) at none:0
iterate at generator.jl:47 [inlined]
mapfoldl_impl(::Function, ::Function, ::NamedTuple{(),Tuple{}}, ::Base.Generator{UnitRange{Int64},getfield(Plots, Symbol(“##279#281”)){Base.Generator{Tuple{Int64,Int64},getfield(Plots, Symbol(“##280#282”)){Float64}},Array{Int64,1}}}) at reduce.jl:55
#mapfoldl#187 at reduce.jl:72 [inlined]
mapfoldl at reduce.jl:72 [inlined]
#mapreduce#191 at reduce.jl:205 [inlined]
mapreduce(::Function, ::Function, ::Base.Generator{UnitRange{Int64},getfield(Plots, Symbol(“##279#281”)){Base.Generator{Tuple{Int64,Int64},getfield(Plots, Symbol(“##280#282”)){Float64}},Array{Int64,1}}}) at reduce.jl:205
minimum(::Base.Generator{UnitRange{Int64},getfield(Plots, Symbol(“##279#281”)){Base.Generator{Tuple{Int64,Int64},getfield(Plots, Symbol(“##280#282”)){Float64}},Array{Int64,1}}}) at reduce.jl:503
showjuno(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::MIME{Symbol(“image/svg+xml”)}, ::Plots.Plot{Plots.PyPlotBackend}) at output.jl:238
show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::MIME{Symbol(“image/svg+xml”)}, ::Plots.Plot{Plots.PyPlotBackend}) at output.jl:195
__binrepr at multimedia.jl:129 [inlined]
_textrepr at multimedia.jl:119 [inlined]
#stringmime#6 at Base64.jl:38 [inlined]
(::getfield(Base64, Symbol(“#kw##stringmime”)))(::NamedTuple{(:context,),Tuple{IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}}}, ::typeof(Base64.stringmime), ::MIME{Symbol(“image/svg+xml”)}, ::Plots.Plot{Plots.PyPlotBackend}) at none:0
#stringmime#7(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Function, ::String, ::Plots.Plot{Plots.PyPlotBackend}) at Base64.jl:39
#stringmime at none:0 [inlined]
displayinplotpane(::Plots.Plot{Plots.PyPlotBackend}) at showdisplay.jl:55
displayandrender(::Plots.Plot{Plots.PyPlotBackend}) at showdisplay.jl:115
(::getfield(Atom, Symbol(“##129#134”)))() at eval.jl:142
#invokelatest#1 at essentials.jl:742 [inlined]
invokelatest at essentials.jl:741 [inlined]
(::getfield(Atom, Symbol(“##128#133”)){String,String,Module})() at eval.jl:141
withpath(::getfield(Atom, Symbol(“##128#133”)){String,String,Module}, ::String) at utils.jl:30
withpath at eval.jl:46 [inlined]
#127 at eval.jl:122 [inlined]
with_logstate(::getfield(Atom, Symbol(“##127#132”)){String,String,Module}, ::Base.CoreLogging.LogState) at logging.jl:395
with_logger at logging.jl:491 [inlined]
#126 at eval.jl:121 [inlined]
hideprompt(::getfield(Atom, Symbol(“##126#131”)){String,String,Module}) at repl.jl:75
macro expansion at eval.jl:120 [inlined]
macro expansion at dynamic.jl:24 [inlined]
(::getfield(Atom, Symbol(“##125#130”)))(::Dict{String,Any}) at eval.jl:109
handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at comm.jl:164
(::getfield(Atom, Symbol(“##19#21”)){Array{Any,1}})() at task.jl:259