def test_is_sequence_of_strings(): y = ['a', 'b', 'c'] assert cbook.is_sequence_of_strings(y) y = np.array(y, dtype=object) assert cbook.is_sequence_of_strings(y)
def __init__(self, fig, eventslist=()): self.fig = fig assert is_sequence_of_strings( eventslist), "Requires a sequence of event name strings" self.eventslist = eventslist
def test_is_sequence_of_strings(): y = ["a", "b", "c"] assert cbook.is_sequence_of_strings(y) y = np.array(y, dtype=object) assert cbook.is_sequence_of_strings(y)
def scatter(self, xs, ys, zs=0, zdir='z', s=20, c='b', *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. ========== ========================================================== 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 = np.ma.ravel(xs) ys = np.ma.ravel(ys) zs = np.ma.ravel(zs) if xs.size != ys.size: raise ValueError("x and y must be the same size") if xs.size != zs.size and zs.size == 1: zs = np.array(zs[0] * xs.size) s = np.ma.ravel(s) # This doesn't have to match x, y in size. cstr = cbook.is_string_like(c) or cbook.is_sequence_of_strings(c) if not cstr: c = np.asanyarray(c) if c.size == xs.size: c = np.ma.ravel(c) xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c) patches = Axes.scatter(self, xs, ys, s=s, c=c, *args, **kwargs) if not cbook.iterable(zs): is_2d = True zs = np.ones(len(xs)) * zs else: is_2d = False art3d.patch_collection_2d_to_3d(patches, zs=zs, zdir=zdir) #FIXME: why is this necessary? if not is_2d: self.auto_scale_xyz(xs, ys, zs, had_data) return patches
def __init__(self, fig, eventslist=()): self.fig = fig if not is_sequence_of_strings(eventslist): raise ValueError("Requires a sequence of event name strings") self.eventslist = eventslist