-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Add ability to toggle legend in the figure options dialog box #30128
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ def convert_limits(lim, converter): | |
| ) | ||
| for name, axis in axis_map.items() | ||
| ]), | ||
| ('Legend visible', axes.legend_ is not None), | ||
| ('(Re-)Generate automatic legend', False), | ||
| ] | ||
|
|
||
|
|
@@ -196,6 +197,7 @@ def apply_callback(data): | |
| title = general.pop(0) | ||
| axes.set_title(title) | ||
| generate_legend = general.pop() | ||
| legend_visible = general.pop() | ||
|
|
||
| for i, (name, axis) in enumerate(axis_map.items()): | ||
| axis_min = general[4*i] | ||
|
|
@@ -256,6 +258,10 @@ def apply_callback(data): | |
| if new_legend: | ||
| new_legend.set_draggable(draggable) | ||
|
|
||
| # toggle legend visibility | ||
| if axes.legend_ is not None: | ||
| axes.legend_.set_visible(legend_visible) | ||
|
Comment on lines
+261
to
+263
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have an issue with this: Either we would need to generate a legend (not so great beacuse we'd need to assume the defaults, equivalent to a |
||
|
|
||
| # Redraw | ||
| figure = axes.get_figure() | ||
| figure.canvas.draw() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS this does not work, because it does not cover the case of an existing legend with
set_visible(False)