Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] How to include a contour plot in the legend? #4187

Open
akriegman opened this issue Apr 28, 2022 · 3 comments
Open

[FR] How to include a contour plot in the legend? #4187

akriegman opened this issue Apr 28, 2022 · 3 comments
Labels

Comments

@akriegman
Copy link

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?

@BeastyBlacksmith
Copy link
Member

Thats currently disabled. See here:

Plots.jl/src/subplots.jl

Lines 42 to 61 in 54a6518

function should_add_to_legend(series::Series)
series.plotattributes[:primary] &&
series.plotattributes[:label] != "" &&
!(
series.plotattributes[:seriestype] in (
:hexbin,
:bins2d,
:histogram2d,
:hline,
:vline,
:contour,
:contourf,
:contour3d,
:surface,
:wireframe,
:heatmap,
:image,
)
)
end

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.

@akriegman
Copy link
Author

I went with the empty plot trick. Thanks!

@t-bltg t-bltg closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2022
@jonniediegelman
Copy link

Can we open this back up? I'd really like to have this feature and the empty plot trick doesn't play well with plot recipes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants