Python matplotlib.mlab.contiguous_regions() Examples
The following are 7
code examples of matplotlib.mlab.contiguous_regions().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.mlab
, or try the search function
.
Example #1
Source File: collections.py From Computable with MIT License | 6 votes |
def span_where(x, ymin, ymax, where, **kwargs): """ Create a BrokenBarHCollection to plot horizontal bars from over the regions in *x* where *where* is True. The bars range on the y-axis from *ymin* to *ymax* A :class:`BrokenBarHCollection` is returned. *kwargs* are passed on to the collection. """ xranges = [] for ind0, ind1 in mlab.contiguous_regions(where): xslice = x[ind0:ind1] if not len(xslice): continue xranges.append((xslice[0], xslice[-1] - xslice[0])) collection = BrokenBarHCollection( xranges, [ymin, ymax - ymin], **kwargs) return collection
Example #2
Source File: collections.py From matplotlib-4-abaqus with MIT License | 6 votes |
def span_where(x, ymin, ymax, where, **kwargs): """ Create a BrokenBarHCollection to plot horizontal bars from over the regions in *x* where *where* is True. The bars range on the y-axis from *ymin* to *ymax* A :class:`BrokenBarHCollection` is returned. *kwargs* are passed on to the collection. """ xranges = [] for ind0, ind1 in mlab.contiguous_regions(where): xslice = x[ind0:ind1] if not len(xslice): continue xranges.append((xslice[0], xslice[-1] - xslice[0])) collection = BrokenBarHCollection( xranges, [ymin, ymax - ymin], **kwargs) return collection
Example #3
Source File: collections.py From neural-network-animation with MIT License | 6 votes |
def span_where(x, ymin, ymax, where, **kwargs): """ Create a BrokenBarHCollection to plot horizontal bars from over the regions in *x* where *where* is True. The bars range on the y-axis from *ymin* to *ymax* A :class:`BrokenBarHCollection` is returned. *kwargs* are passed on to the collection. """ xranges = [] for ind0, ind1 in mlab.contiguous_regions(where): xslice = x[ind0:ind1] if not len(xslice): continue xranges.append((xslice[0], xslice[-1] - xslice[0])) collection = BrokenBarHCollection( xranges, [ymin, ymax - ymin], **kwargs) return collection
Example #4
Source File: test_mlab.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_contiguous_regions(): a, b, c = 3, 4, 5 # Starts and ends with True mask = [True]*a + [False]*b + [True]*c expected = [(0, a), (a+b, a+b+c)] with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected d, e = 6, 7 # Starts with True ends with False mask = mask + [False]*e with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # Starts with False ends with True mask = [False]*d + mask[:-e] expected = [(d, d+a), (d+a+b, d+a+b+c)] with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # Starts and ends with False mask = mask + [False]*e with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # No True in mask assert mlab.contiguous_regions([False]*5) == [] # Empty mask assert mlab.contiguous_regions([]) == []
Example #5
Source File: collections.py From ImageFusion with MIT License | 6 votes |
def span_where(x, ymin, ymax, where, **kwargs): """ Create a BrokenBarHCollection to plot horizontal bars from over the regions in *x* where *where* is True. The bars range on the y-axis from *ymin* to *ymax* A :class:`BrokenBarHCollection` is returned. *kwargs* are passed on to the collection. """ xranges = [] for ind0, ind1 in mlab.contiguous_regions(where): xslice = x[ind0:ind1] if not len(xslice): continue xranges.append((xslice[0], xslice[-1] - xslice[0])) collection = BrokenBarHCollection( xranges, [ymin, ymax - ymin], **kwargs) return collection
Example #6
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_contiguous_regions(): a, b, c = 3, 4, 5 # Starts and ends with True mask = [True]*a + [False]*b + [True]*c expected = [(0, a), (a+b, a+b+c)] with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected d, e = 6, 7 # Starts with True ends with False mask = mask + [False]*e with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # Starts with False ends with True mask = [False]*d + mask[:-e] expected = [(d, d+a), (d+a+b, d+a+b+c)] with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # Starts and ends with False mask = mask + [False]*e with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # No True in mask assert mlab.contiguous_regions([False]*5) == [] # Empty mask assert mlab.contiguous_regions([]) == []
Example #7
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_contiguous_regions(): a, b, c = 3, 4, 5 # Starts and ends with True mask = [True]*a + [False]*b + [True]*c expected = [(0, a), (a+b, a+b+c)] with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected d, e = 6, 7 # Starts with True ends with False mask = mask + [False]*e with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # Starts with False ends with True mask = [False]*d + mask[:-e] expected = [(d, d+a), (d+a+b, d+a+b+c)] with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # Starts and ends with False mask = mask + [False]*e with pytest.warns(MatplotlibDeprecationWarning): assert mlab.contiguous_regions(mask) == expected # No True in mask assert mlab.contiguous_regions([False]*5) == [] # Empty mask assert mlab.contiguous_regions([]) == []