Python matplotlib.cbook.delete_masked_points() Examples
The following are 29
code examples of matplotlib.cbook.delete_masked_points().
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.cbook
, or try the search function
.
Example #1
Source File: quiver.py From CogAlg with MIT License | 6 votes |
def set_offsets(self, xy): """ Set the offsets for the barb polygons. This saves the offsets passed in and masks them as appropriate for the existing U/V data. Parameters ---------- xy : sequence of pairs of floats """ self.x = xy[:, 0] self.y = xy[:, 1] x, y, u, v = cbook.delete_masked_points( self.x.ravel(), self.y.ravel(), self.u, self.v) _check_consistent_shapes(x, y, u, v) xy = np.column_stack((x, y)) mcollections.PolyCollection.set_offsets(self, xy) self.stale = True
Example #2
Source File: quiver.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def set_offsets(self, xy): """ Set the offsets for the barb polygons. This saves the offsets passed in and actually sets version masked as appropriate for the existing U/V data. *offsets* should be a sequence. Parameters ---------- offsets : sequence of pairs of floats """ self.x = xy[:, 0] self.y = xy[:, 1] x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) _check_consistent_shapes(x, y, u, v) xy = np.column_stack((x, y)) mcollections.PolyCollection.set_offsets(self, xy) self.stale = True
Example #3
Source File: test_cbook.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_datetime(self): actual = dmp(self.arr_dt, self.arr3) ind = [0, 1, 5] expected = (self.arr_dt2.take(ind), self.arr3.take(ind).compressed()) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #4
Source File: quiver.py From twitter-stock-recommendation with MIT License | 5 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v, c) _check_consistent_shapes(x, y, u, v, c) else: x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) _check_consistent_shapes(x, y, u, v) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis])) self._offsets = xy self.stale = True
Example #5
Source File: test_cbook.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_rgba(self): actual = dmp(self.arr3, self.arr_rgba) ind = [0, 1, 5] expected = (self.arr3.take(ind).compressed(), self.arr_rgba.take(ind, axis=0)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #6
Source File: test_cbook.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_datetime(self): actual = dmp(self.arr_dt, self.arr3) ind = [0, 1, 5] expected = (self.arr_dt2.take(ind), self.arr3.take(ind).compressed()) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #7
Source File: test_cbook.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_string_seq(self): actual = dmp(self.arr_s, self.arr1) ind = [0, 1, 2, 5] expected = (self.arr_s2.take(ind), self.arr2.take(ind)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #8
Source File: test_cbook.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_bad_first_arg(self): with pytest.raises(ValueError): dmp('a string', self.arr0)
Example #9
Source File: quiver.py From coffeegrindsize with MIT License | 5 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v, c) _check_consistent_shapes(x, y, u, v, c) else: x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) _check_consistent_shapes(x, y, u, v) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.column_stack((x, y)) self._offsets = xy self.stale = True
Example #10
Source File: test_cbook.py From coffeegrindsize with MIT License | 5 votes |
def test_rgba(self): actual = dmp(self.arr3, self.arr_rgba) ind = [0, 1, 5] expected = (self.arr3.take(ind).compressed(), self.arr_rgba.take(ind, axis=0)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #11
Source File: test_cbook.py From coffeegrindsize with MIT License | 5 votes |
def test_datetime(self): actual = dmp(self.arr_dt, self.arr3) ind = [0, 1, 5] expected = (self.arr_dt2.take(ind), self.arr3.take(ind).compressed()) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #12
Source File: test_cbook.py From coffeegrindsize with MIT License | 5 votes |
def test_string_seq(self): actual = dmp(self.arr_s, self.arr1) ind = [0, 1, 2, 5] expected = (self.arr_s2.take(ind), self.arr2.take(ind)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #13
Source File: test_cbook.py From coffeegrindsize with MIT License | 5 votes |
def test_bad_first_arg(self): with pytest.raises(ValueError): dmp('a string', self.arr0)
Example #14
Source File: quiver.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v, c) _check_consistent_shapes(x, y, u, v, c) else: x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) _check_consistent_shapes(x, y, u, v) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.column_stack((x, y)) self._offsets = xy self.stale = True
Example #15
Source File: test_cbook.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_rgba(self): actual = dmp(self.arr3, self.arr_rgba) ind = [0, 1, 5] expected = (self.arr3.take(ind).compressed(), self.arr_rgba.take(ind, axis=0)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #16
Source File: quiver.py From Computable with MIT License | 5 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v, c) else: x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis])) self._offsets = xy
Example #17
Source File: test_cbook.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_string_seq(self): actual = dmp(self.arr_s, self.arr1) ind = [0, 1, 2, 5] expected = (self.arr_s2.take(ind), self.arr2.take(ind)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #18
Source File: test_cbook.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_bad_first_arg(self): with pytest.raises(ValueError): dmp('a string', self.arr0)
Example #19
Source File: quiver.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v, c) _check_consistent_shapes(x, y, u, v, c) else: x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) _check_consistent_shapes(x, y, u, v) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.column_stack((x, y)) self._offsets = xy self.stale = True
Example #20
Source File: quiver.py From neural-network-animation with MIT License | 5 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v, c) else: x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis])) self._offsets = xy
Example #21
Source File: test_cbook.py From neural-network-animation with MIT License | 5 votes |
def test_rgba(self): actual = dmp(self.arr3, self.arr_rgba) ind = [0, 1, 5] expected = (self.arr3.take(ind).compressed(), self.arr_rgba.take(ind, axis=0)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #22
Source File: test_cbook.py From neural-network-animation with MIT License | 5 votes |
def test_datetime(self): actual = dmp(self.arr_dt, self.arr3) ind = [0, 1, 5] expected = (self.arr_dt2.take(ind), self.arr3.take(ind).compressed()) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #23
Source File: test_cbook.py From neural-network-animation with MIT License | 5 votes |
def test_string_seq(self): actual = dmp(self.arr_s, self.arr1) ind = [0, 1, 2, 5] expected = (self.arr_s2.take(ind), self.arr2.take(ind)) assert_array_equal(actual[0], expected[0]) assert_array_equal(actual[1], expected[1])
Example #24
Source File: test_cbook.py From neural-network-animation with MIT License | 5 votes |
def test_bad_first_arg(self): dmp('a string', self.arr0)
Example #25
Source File: quiver.py From matplotlib-4-abaqus with MIT License | 5 votes |
def set_offsets(self, xy): """ Set the offsets for the barb polygons. This saves the offets passed in and actually sets version masked as appropriate for the existing U/V data. *offsets* should be a sequence. ACCEPTS: sequence of pairs of floats """ self.x = xy[:, 0] self.y = xy[:, 1] x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis])) collections.PolyCollection.set_offsets(self, xy)
Example #26
Source File: quiver.py From matplotlib-4-abaqus with MIT License | 5 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v, c) else: x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis])) self._offsets = xy
Example #27
Source File: quiver.py From Computable with MIT License | 5 votes |
def set_offsets(self, xy): """ Set the offsets for the barb polygons. This saves the offets passed in and actually sets version masked as appropriate for the existing U/V data. *offsets* should be a sequence. ACCEPTS: sequence of pairs of floats """ self.x = xy[:, 0] self.y = xy[:, 1] x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis])) collections.PolyCollection.set_offsets(self, xy)
Example #28
Source File: axes3d.py From GraphicDesignPatternByPython with MIT License | 4 votes |
def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True, *args, **kwargs): ''' Create a scatter plot. ============ ======================================================== Argument Description ============ ======================================================== *xs*, *ys* Positions of data points. *zs* Either an array of the same length as *xs* and *ys* or a single value to place all points in the same plane. Default is 0. *zdir* Which direction to use as z ('x', 'y' or 'z') when plotting a 2D set. *s* Size in points^2. It is a scalar or an array of the same length as *x* and *y*. *c* A color. *c* can be a single color format string, or a sequence of color specifications of length *N*, or a sequence of *N* numbers to be mapped to colors using the *cmap* and *norm* specified via kwargs (see below). Note that *c* should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. *c* can be a 2-D array in which the rows are RGB or RGBA, however, including the case of a single row to specify the same color for all points. *depthshade* Whether or not to shade the scatter markers to give the appearance of depth. Default is *True*. ============ ======================================================== Keyword arguments are passed on to :func:`~matplotlib.axes.Axes.scatter`. Returns a :class:`~mpl_toolkits.mplot3d.art3d.Patch3DCollection` ''' had_data = self.has_data() xs, ys, zs = np.broadcast_arrays( *[np.ravel(np.ma.filled(t, np.nan)) for t in [xs, ys, zs]]) s = np.ma.ravel(s) # This doesn't have to match x, y in size. xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c) patches = super().scatter(xs, ys, s=s, c=c, *args, **kwargs) is_2d = not cbook.iterable(zs) zs = np.broadcast_to(zs, len(xs)) art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir, depthshade=depthshade) if self._zmargin < 0.05 and xs.size > 0: self.set_zmargin(0.05) #FIXME: why is this necessary? if not is_2d: self.auto_scale_xyz(xs, ys, zs, had_data) return patches
Example #29
Source File: quiver.py From CogAlg with MIT License | 4 votes |
def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() # Flip needs to have the same number of entries as everything else. # Use broadcast_to to avoid a bloated array of identical values. # (can't rely on actual broadcasting) if len(self.flip) == 1: flip = np.broadcast_to(self.flip, self.u.shape) else: flip = self.flip if C is not None: c = ma.masked_invalid(C, copy=False).ravel() x, y, u, v, c, flip = cbook.delete_masked_points( self.x.ravel(), self.y.ravel(), self.u, self.v, c, flip.ravel()) _check_consistent_shapes(x, y, u, v, c, flip) else: x, y, u, v, flip = cbook.delete_masked_points( self.x.ravel(), self.y.ravel(), self.u, self.v, flip.ravel()) _check_consistent_shapes(x, y, u, v, flip) magnitude = np.hypot(u, v) flags, barbs, halves, empty = self._find_tails(magnitude, self.rounding, **self.barb_increments) # Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, flip) self.set_verts(plot_barbs) # Set the color array if C is not None: self.set_array(c) # Update the offsets in case the masked data changed xy = np.column_stack((x, y)) self._offsets = xy self.stale = True