Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63894f9

Browse files
author
anykraus
committed
Added a checkbox for (re-)generating auto-legend
Checkbox added that controls if an automatic legend is re-generated, or generated for the first time. This checkbox defaults to False, as it generates a simple legend when set to True, see matplotlib.pyplot.legend(), which clobbers any carefully handcrafted legend.
1 parent 0bc4c52 commit 63894f9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/backends/qt4_editor/figureoptions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def figure_edit(axes, parent=None):
5454
('Min', ymin), ('Max', ymax),
5555
('Label', axes.get_ylabel()),
5656
('Scale', [axes.get_yscale(), 'linear', 'log'])
57+
sep,
58+
('(Re-)Generate automatic legend', False) #defaults to False, as it clobbers carefully hand crafted legends /2014-04-22
5759
]
5860

5961
if has_curve:
@@ -98,7 +100,7 @@ def apply_callback(data):
98100
general, = data
99101

100102
# Set / General
101-
title, xmin, xmax, xlabel, xscale, ymin, ymax, ylabel, yscale = general
103+
title, xmin, xmax, xlabel, xscale, ymin, ymax, ylabel, yscale, generate_legend = general #/2014-04-22
102104
axes.set_xscale(xscale)
103105
axes.set_yscale(yscale)
104106
axes.set_title(title)
@@ -123,9 +125,9 @@ def apply_callback(data):
123125
line.set_markerfacecolor(markerfacecolor)
124126
line.set_markeredgecolor(markeredgecolor)
125127

126-
# re-generate legend, if there is one. Stefan Kraus/tacaswell 2014-04-02
127-
if axes.legend_ is not None:
128-
axes.legend()
128+
# re-generate legend, if checkbox is checked. Stefan Kraus/tacaswell 2014-04-22
129+
if generate_legend:
130+
new_legend = axes.legend()
129131

130132
# Redraw
131133
figure = axes.get_figure()

0 commit comments

Comments
 (0)