8000 see TODO · rmorshea/matplotlib@d772a94 · GitHub
[go: up one dir, main page]

Skip to content

Commit d772a94

Browse files
committed
see TODO
1 parent 4cd90a3 commit d772a94

28 files changed

+188
-114
lines changed

TODO.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@
5555
6.0 : clipon
5656
6.0 : url
5757
6.0 : gid
58-
59-
0.0 : label
58+
6.0 : label
59+
6.0 : contains
6060
0.0 : picker
61-
0.0 : contains
6261
0.0 : agg_filter
6362
...
6463
...

lib/matplotlib/artist.py

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from .traitlets import (Instance, Configurable, gTransformInstance, Bool, Undefined, Union,
1919
BaseDescriptor, getargspec, PrivateMethodMixin, Float, TraitError,
20-
Unicode)
20+
Unicode, Stringlike, Callable)
2121

2222
from urlparse import urlparse
2323

@@ -209,11 +209,13 @@ def _clipon_changed(self, name, old, new):
209209
self.pchanged()
210210
self.stale = True
211211

212-
# label = Unicode('', allow_none=True)
212+
label = Stringlike('', allow_none=True)
213+
214+
def _label_changed(self, name, old, new):
215+
self.pchanged()
213216

214-
# def _label_changed(self, name, old, new):
215-
# self.pchanged()
216-
# self.stale = True
217+
218+
_contains = Callable(None, allow_none=True)
217219

218220
url = Unicode(allow_none=True)
219221

@@ -234,9 +236,9 @@ def __init__(self):
234236
# self.clipbox = None
235237
# self._clippath = None
236238
# self._clipon = True
237-
self._label = ''
239+
# self._label = ''
238240
self._picker = None
239-
self._contains = None
241+
# self._contains = None
240242
# self._rasterized = None
241243
self._agg_filter = None
242244
self._mouseover = False
@@ -525,32 +527,35 @@ def contains(self, mouseevent):
525527
selection, such as which points are contained in the pick radius. See
526528
individual artists for details.
527529
"""
528-
if six.callable(self._contains):
530+
#self._contains should already be callable
531+
if self._contains is not None:
529532
return self._contains(self, mouseevent)
530533
warnings.warn("'%s' needs 'contains' method" % self.__class__.__name__)
531534
return False, {}
532535

533-
def set_contains(self, picker):
534-
"""
535-
Replace the contains test used by this artist. The new picker
536-
should be a callable function which determines whether the
537-
artist is hit by the mouse event::
536+
#!DEPRECATED
537+
# def set_contains(self, picker):
538+
# """
539+
# Replace the contains test used by this artist. The new picker
540+
# should be a callable function which determines whether the
541+
# artist is hit by the mouse event::
538542

539-
hit, props = picker(artist, mouseevent)
543+
# hit, props = picker(artist, mouseevent)
540544

541-
If the mouse event is over the artist, return *hit* = *True*
542-
and *props* is a dictionary of properties you want returned
543-
with the contains test.
545+
# If the mouse event is over the artist, return *hit* = *True*
546+
# and *props* is a dictionary of properties you want returned
547+
# with the contains test.
544548

545-
ACCEPTS: a callable function
546-
"""
547-
self._contains = picker
549+
# ACCEPTS: a callable function
550+
# """
551+
# self._contains = picker
548552

549-
def get_contains(self):
550-
"""
551-
Return the _contains test used by the artist, or *None* for default.
552-
"""
553-
return self._contains
553+
#!DEPRECATED
554+
# def get_contains(self):
555+
# """
556+
# Return the _contains test used by the artist, or *None* for default.
557+
# """
558+
# return self._contains
554559

555560
# def pickable(self):
556561
# 'Return *True* if :class:`Artist` is pickable.'
@@ -1004,25 +1009,25 @@ def update(self, props):
10041009
self.stale = True
10051010

10061011
#!DEPRECATED
1007-
def get_label(self):
1008-
"""
1009-
Get the label used for this artist in the legend.
1010-
"""
1011-
return self._label
1012+
# def get_label(self):
1013+
# """
1014+
# Get the label used for this artist in the legend.
1015+
# """
1016+
# return self._label
10121017

10131018
#!DEPRECATED
1014-
def set_label(self, s):
1015-
"""
1016-
Set the label to *s* for auto legend.
1019+
# def set_label(self, s):
1020+
# """
1021+
# Set the label to *s* for auto legend.
10171022

1018-
ACCEPTS: string or anything printable with '%s' conversion.
1019-
"""
1020-
if s is not None:
1021-
self._label = '%s' % (s, )
1022-
else:
1023-
self._label = None
1024-
self.pchanged()
1025-
self.stale = True
1023+
# ACCEPTS: string or anything printable with '%s' conversion.
1024+
# """
1025+
# if s is not None:
1026+
# self._label = '%s' % (s, )
1027+
# else:
1028+
# self._label = None
1029+
# self.pchanged()
1030+
# self.stale = True
10261031

10271032
def get_zorder(self):
10281033
"""
@@ -1050,7 +1055,7 @@ def update_from(self, other):
10501055
self.private('clipbox', other.clipbox)
10511056
self.private('clipon', other.clipon)
10521057
self.private('clippath', other.clippath)
1053-
self._label = other._label
1058+
self.private('label', other.label)
10541059
self._sketch = other._sketch
10551060
self._path_effects = other._path_effects
10561061
self.pchanged()

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def get_xlabel(self):
180180
"""
181181
Get the xlabel text string.
182182
"""
183-
label = self.xaxis.get_label()
183+
label = self.xaxis.label
184184
return label.get_text()
185185

186186
@docstring.dedent_interpd
@@ -212,7 +212,7 @@ def get_ylabel(self):
212212
"""
213213
Get the ylabel text string.
214214
"""
215-
label = self.yaxis.get_label()
215+
label = self.yaxis.label
216216
return label.get_text()
217217

218218
@docstring.dedent_interpd
@@ -258,7 +258,7 @@ def _get_legend_handles(self, legend_handler_map=None):
258258
has_handler = mlegend.Legend.get_legend_handler
259259

260260
for handle in handles_original:
261-
label = handle.get_label()
261+
label = handle.label if hasattr(handle,'label') else handle.get_label()
262262
if label != '_nolegend_' and has_handler(handler_map, handle):
263263
yield handle
264264

@@ -275,7 +275,7 @@ def get_legend_handles_labels(self, legend_handler_map=None):
275275
handles = []
276276
labels = []
277277
for handle in self._get_legend_handles(legend_handler_map):
278-
label = handle.get_label()
278+
label = handle.label if hasattr(handle,'label') else handle.get_label()
279279
if label and not label.startswith('_'):
280280
handles.append(handle)
281281
labels.append(label)
@@ -300,7 +300,7 @@ def legend(self, *args, **kwargs):
300300
301301
line, = ax.plot([1, 2, 3], label='Inline label')
302302
# Overwrite the label by calling the method.
303-
line.set_label('Label via method')
303+
line.label = 'Label via method'
304304
ax.legend()
305305
306306
Specific lines can be excluded from the automatic legend element
@@ -498,7 +498,7 @@ def legend(self, *args, **kwargs):
498498
handles, labels = zip(*zip(handles, labels))
499499

500500
elif handles is not None and labels is None:
501-
labels = [handle.get_label() for handle in handles]
501+
labels = [handle.label for handle in handles]
502502
for label, handle in zip(labels[:], handles[:]):
503503
if label.startswith('_'):
504504
warnings.warn('The handle {!r} has a label of {!r} which '
@@ -2598,15 +2598,15 @@ def pie(self, x, explode=None, labels=None, colors=None,
25982598
**wedgeprops)
25992599
slices.append(w)
26002600
self.add_patch(w)
2601-
w.set_label(label)
2601+
w.label = label
26022602

26032603
if shadow:
26042604
# make sure to add a shadow after the call to
26052605
# add_patch so the figure and transform props will be
26062606
# set
26072607
shad = mpatches.Shadow(w, -0.02, -0.02)
26082608
shad.set_zorder(0.9 * w.get_zorder())
2609-
shad.set_label('_nolegend_')
2609+
shad.label = '_nolegend_'
26102610
self.add_patch(shad)
26112611

26122612
xt = x + labeldistance * radius * math.cos(thetam)
@@ -6210,13 +6210,13 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
62106210
p = patch[0]
62116211
p.update(kwargs)
62126212
if lbl is not None:
6213-
p.set_label(lbl)
6213+
p.label = lbl
62146214

62156215
p.set_snap(False)
62166216

62176217
for p in patch[1:]:
62186218
p.update(kwargs)
6219-
p.set_label('_nolegend_')
6219+
p.label = '_nolegend_'
62206220

62216221
if binsgiven:
62226222
if orientation == 'vertical':

lib/matplotlib/axes/_base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def __init__(self, fig, rect,
509509
#warnings.warn(
510510
# 'shared axes: "adjustable" is being changed to "datalim"')
511511
self._adjustable = 'datalim'
512-
self.set_label(label)
512+
self.label = label
513513

514514
if self.figure == fig:
515515
self.force_callback('figure')
@@ -1688,9 +1688,9 @@ def add_collection(self, collection, autolim=True):
16881688
16891689
Returns the collection.
16901690
"""
1691-
label = collection.get_label()
1691+
label = collection.label
16921692
if not label:
1693-
collection.set_label('_collection%d' % len(self.collections))
1693+
collection.label = '_collection%d' % len(self.collections)
16941694
self.collections.append(collection)
16951695
self._set_artist_props(collection)
16961696

@@ -1726,8 +1726,8 @@ def add_line(self, line):
17261726
line.set_clip_path(self.patch)
17271727

17281728
self._update_line_limits(line)
1729-
if not line.get_label():
1730-
line.set_label('_line%d' % len(self.lines))
1729+
if not line.label:
1730+
line.label = '_line%d' % len(self.lines)
17311731
self.lines.append(line)
17321732
line._remove_method = lambda h: self.lines.remove(h)
17331733
return line
@@ -3622,7 +3622,8 @@ def contains(self, mouseevent):
36223622
36233623
Returns *True* / *False*, {}
36243624
"""
3625-
if six.callable(self._contains):
3625+
# self._contains should already be callable
3626+
if self._contains is not None:
36263627
return self._contains(self, mouseevent)
36273628

36283629
return self.patch.contains(mouseevent)

lib/matplotlib/axis.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def contains(self, mouseevent):
193193
This function always returns false. It is more useful to test if the
194194
axis as a whole contains the mouse rather than the set of tick marks.
195195
"""
196-
if six.callable(self._contains):
196+
# self._contains should already be callable
197+
if self._contains is not None:
197198
return self._contains(self, mouseevent)
198199
return False, {}
199200

@@ -1661,7 +1662,8 @@ class XAxis(Axis):
16611662
def contains(self, mouseevent):
16621663
"""Test whether the mouse event occured in the x axis.
16631664
"""
1664-
if six.callable(self._contains):
1665+
# self._contains should already be callable
1666+
if self._contains is not None:
16651667
return self._contains(self, mouseevent)
16661668

16671669
x, y = mouseevent.x, mouseevent.y
@@ -1986,7 +1988,8 @@ def contains(self, mouseevent):
19861988
19871989
Returns *True* | *False*
19881990
"""
1989-
if six.callable(self._contains):
1991+
#self.contains should already be callable
1992+
if self._contains is not None:
19901993
return self._contains(self, mouseevent)
19911994

19921995
x, y = mouseevent.x, mouseevent.y

lib/matplotlib/backends/backend_gtk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ def show(self):
940940

941941
# add the new
942942
for line in self.lines:
943-
cbox.append_text(line.get_label())
943+
cbox.append_text(line.label)
944944
cbox.set_active(0)
945945

946946
self._updateson = True

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ def show(self):
10031003

10041004
# add the new
10051005
for line in self.lines:
1006-
cbox.append_text(line.get_label())
1006+
cbox.append_text(line.label)
10071007
cbox.set_active(0)
10081008

10091009
self._updateson = True

lib/matplotlib/backends/backend_nbagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def connection_info():
7777
result = []
7878
for manager in Gcf.get_all_fig_managers():
7979
fig = manager.canvas.figure
80-
result.append('{0} - {0}'.format((fig.get_label() or
80+
result.append('{0} - {0}'.format((fig.label or
8181
"Figure {0}".format(manager.num)),
8282
manager.web_sockets))
8383
if not is_interactive():

lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ def edit_parameters(self):
620620
for axes in allaxes:
621621
title = axes.get_title()
622622
ylabel = axes.get_ylabel()
623-
label = axes.get_label()
623+
label = axes.label
624624
if title:
625625
fmt = "%(title)s"
626626
if ylabel:

lib/matplotlib/backends/backend_webagg_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def handle_event(self, event):
323323
# TODO: Be more suspicious of the input
324324
getattr(self.toolbar, event['name'])()
325325
elif e_type == 'refresh':
326-
figure_label = self.figure.get_label()
326+
figure_label = self.figure.label
327327
if not figure_label:
328328
figure_label = "Figure {0}".format(self.manager.num)
329329
self.send_event('figure_label', label=figure_label)

0 commit comments

Comments
 (0)
0