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

Skip to content

Commit 98e37e8

Browse files
pelsonmdboom
authored andcommitted
Fixed failing bbox_inches='tight' case when a contour collection is empty.
Conflicts: lib/matplotlib/tests/test_collections.py
1 parent 4779119 commit 98e37e8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/matplotlib/collections.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,13 @@ def get_datalim(self, transData):
183183
# get_path_collection_extents handles nan but not masked arrays
184184
offsets.shape = (-1, 2) # Make it Nx2
185185

186-
result = mpath.get_path_collection_extents(
187-
transform.frozen(), paths, self.get_transforms(),
188-
offsets, transOffset.frozen())
189-
result = result.inverse_transformed(transData)
186+
if paths:
187+
result = mpath.get_path_collection_extents(
188+
transform.frozen(), paths, self.get_transforms(),
189+
offsets, transOffset.frozen())
190+
result = result.inverse_transformed(transData)
191+
else:
192+
result = transforms.Bbox([[0, 0], [0, 0]])
190193
return result
191194

192195
def get_window_extent(self, renderer):

lib/matplotlib/transforms.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,11 @@ def __init__(self, points, **kwargs):
747747
:meth:`from_bounds` and :meth:`from_extents`.
748748
"""
749749
BboxBase.__init__(self, **kwargs)
750-
self._points = np.asarray(points, np.float_)
750+
points = np.asarray(points, np.float_)
751+
if points.shape != (2, 2):
752+
raise ValueError('Bbox points must be of the form '
753+
'"[[x0, y0], [x1, y1]]".')
754+
self._points = points
751755
self._minpos = np.array([0.0000001, 0.0000001])
752756
self._ignore = True
753757
# it is helpful in some contexts to know if the bbox is a

0 commit comments

Comments
 (0)