8000 WIP : major Axes refactor by tacaswell · Pull Request #3944 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

WIP : major Axes refactor #3944

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP : use container to draw errorbar
tests are still failing
  • Loading branch information
tacaswell committed Mar 8, 2015
commit dd4051e181d3ae52f4868be17bd330d40ed72ba7
21 changes: 13 additions & 8 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import six
from six.moves import reduce, xrange, zip, zip_longest

import itertools
import math
import warnings

Expand Down Expand Up @@ -35,7 +35,8 @@
import matplotlib.transforms as mtransforms
import matplotlib.tri as mtri
import matplotlib.transforms as mtrans
from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
from matplotlib.container import (BarContainer, ErrorbarContainer,
StemContainer, Container)
from matplotlib.axes._base import _AxesBase
from matplotlib.axes._base import _process_plot_format

Expand Down Expand Up @@ -2755,7 +2756,7 @@ def xywhere(xs, ys, mask):

if xerr is not None:
if (iterable(xerr) and len(xerr) == 2 and
iterable(xerr[0]) and iterable(xerr[1])):
iterable(xerr[0]) and iterable(xerr[1])):
# using list comps rather than arrays to preserve units
left = [thisx - thiserr for (thisx, thiserr)
in cbook.safezip(x, xerr[0])]
Expand Down Expand Up @@ -2886,14 +2887,18 @@ def xywhere(xs, ys, mask):
self.autoscale_view()
self._hold = holdstate

errorbar_container = ErrorbarContainer((l0, tuple(caplines),
tuple(barcols)),
# hack to put these artist in the right place in the
# draw tree
for ll in itertools.chain((l0, ), caplines, barcols):
ll.remove()

errorbar_container = ErrorbarContainer((l0,
Container(caplines),
Container(barcols)),
has_xerr=(xerr is not None),
has_yerr=(yerr is not None),
label=label)
self.containers.append(errorbar_container)

return errorbar_container # (l0, caplines, barcols)
return self.add_container(errorbar_container)

def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
positions=None, widths=None, patch_artist=False,
Expand Down
13 changes: 10 additions & 3 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,13 +1605,19 @@ def add_container(self, container):
Add a :class:`~matplotlib.container.Container` instance
to the axes.

Returns the collection.
Returns the container.
"""
container.set_axes(self)
self._set_artist_props(container)
self.containers.append(container)

container.set_clip_path(self.patch)
container.set_remove_method(lambda h: self.containers.remove(h))

label = container.get_label()
if not label:
container.set_label('_container%d' % len(self.containers))
self.containers.append(container)
container.set_remove_method(lambda h: self.containers.remove(h))

return container

def relim(self, visible_only=False):
Expand Down Expand Up @@ -1998,6 +2004,7 @@ def draw(self, renderer=None, inframe=False):
artists.extend(self.lines)
artists.extend(self.texts)
artists.extend(self.artists)
artists.extend(self.containers)

# the frame draws the edges around the axes patch -- we
# decouple these so the patch can be in the background and the
Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Container(tuple, Artist):
"""
Base class for containers.
"""
_no_broadcast = ['label', ]
_no_broadcast = ['label', 'visible', 'zorder', 'animated',
'agg_filter']

def __repr__(self):
return "<Container object of %d artists>" % (len(self))
Expand All @@ -22,7 +23,7 @@ def __init__(self, kl, label=None, **kwargs):
# set up the artist details
Artist.__init__(self, **kwargs)
# for some reason we special case label
self.set_label(label=label)
self.set_label(label)

def remove(self):
# remove the children
Expand Down
0