When using contour
(not contourf
) with Plots.jl
, is there a way to force all the contour lines to be a single fixed color?
contour(rand(10, 10), color=:blue)
Seems to be broken with the PyPlot
backend:
MethodError: no method matching get_colorscheme(::RGBA{Float64})
Closest candidates are:
get_colorscheme(::PlotUtils.AbstractColorList) at ~/.julia/packages/PlotUtils/NE7U1/src/colorschemes.jl:4
get_colorscheme(::AbstractVector{<:Colorant}) at ~/.julia/packages/PlotUtils/NE7U1/src/colorschemes.jl:303
get_colorscheme(::AbstractVector) at ~/.julia/packages/PlotUtils/NE7U1/src/colorschemes.jl:304
...
Stacktrace:
[1] cgrad(::RGBA{Float64}; kwargs::Base.Pairs{Symbol, Nothing, Tuple{Symbol}, NamedTuple{(:alpha,), Tuple{Nothing}}})
@ PlotUtils ~/.julia/packages/PlotUtils/NE7U1/src/colorschemes.jl:244
[2] py_linecolormap(series::Plots.Series)
@ Plots ~/.julia/packages/Plots/SkUg1/src/backends/pyplot.jl:255
[3] py_add_series(plt::Plots.Plot{Plots.PyPlotBackend}, series::Plots.Series)
@ Plots ~/.julia/packages/Plots/SkUg1/src/backends/pyplot.jl:600
[4] _before_layout_calcs(plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/backends/pyplot.jl:1034
[5] prepare_output(plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/plot.jl:218
[6] show(io::Base64.Base64EncodePipe, m::MIME{Symbol("image/png")}, plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/output.jl:201
[7] base64encode(::Function, ::MIME{Symbol("image/png")}, ::Vararg{Any}; context::Nothing)
@ Base64 /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Base64/src/encode.jl:209
[8] base64encode
@ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Base64/src/encode.jl:206 [inlined]
[9] _ijulia_display_dict(plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/ijulia.jl:44
[10] display_dict(plt::Plots.Plot{Plots.PyPlotBackend})
@ Plots ~/.julia/packages/Plots/SkUg1/src/init.jl:91
[11] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[12] invokelatest
@ ./essentials.jl:714 [inlined]
[13] execute_request(socket::ZMQ.Socket, msg::IJulia.Msg)
@ IJulia ~/.julia/packages/IJulia/AQu2H/src/execute_request.jl:112
[14] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[15] invokelatest
@ ./essentials.jl:714 [inlined]
[16] eventloop(socket::ZMQ.Socket)
@ IJulia ~/.julia/packages/IJulia/AQu2H/src/eventloop.jl:8
[17] (::IJulia.var"#15#18")()
@ IJulia ./task.jl:429
Simple
It works by feeding a singleton array of colours:
using Plots; pyplot()
contour(rand(10, 10), c=[:blue])