Plots.jl
Plots.jl copied to clipboard
[FR] How to include a contour plot in the legend?
I am using a contour plot with a single level to plot an equipotential. I'd like to have a legend entry for this curve instead of the colorbar, since the colorbar isn't very useful when there's only one level. I managed to hide the color bar, but I was unable to get a legend entry to appear. MWE:
contour(
-1:0.1:1, -1:0.1:1, (x, y) -> sin(x*y),
levels = [0.2],
colorbar = false,
label = "line", # does nothing
)
Any ideas? Can this feature be added?
Thats currently disabled. See here: https://github.com/JuliaPlots/Plots.jl/blob/54a6518d59498fb24b5c25a90cd91ceadb7e26de/src/subplots.jl#L42-L61
You could check out, what the side-effects are of enabling it and play with it in a PR.
As a workaround you could add an empty plot with a legend entry.
I went with the empty plot trick. Thanks!