desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'*norm* is an instance of :class:`colors.Normalize` or one of its subclasses, used to map luminance to 0-1. *cmap* is a :mod:`cm` colormap instance, for example :data:`cm.jet`'
def __init__(self, norm=None, cmap=None):
self.callbacksSM = cbook.CallbackRegistry(('changed',)) if (cmap is None): cmap = get_cmap() if (norm is None): norm = colors.Normalize() self._A = None self.norm = norm self.cmap = cmap self.colorbar = None self.update_dict = {'array': False}
'set the colorbar image and axes associated with mappable'
def set_colorbar(self, im, ax):
self.colorbar = (im, ax)
'Return a normalized rgba array corresponding to *x*. If *x* is already an rgb array, insert *alpha*; if it is already rgba, return it unchanged. If *bytes* is True, return rgba as 4 uint8s instead of 4 floats.'
def to_rgba(self, x, alpha=1.0, bytes=False):
try: if (x.ndim == 3): if (x.shape[2] == 3): if (x.dtype == np.uint8): alpha = np.array((alpha * 255), np.uint8) (m, n) = x.shape[:2] xx = np.empty(shape=(m, n, 4), dtype=x.dtype) xx[:, :, :3] = x ...
'Set the image array from numpy array *A*'
def set_array(self, A):
self._A = A self.update_dict['array'] = True
'Return the array'
def get_array(self):
return self._A
'return the colormap'
def get_cmap(self):
return self.cmap
'return the min, max of the color limits for image scaling'
def get_clim(self):
return (self.norm.vmin, self.norm.vmax)
'set the norm limits for image scaling; if *vmin* is a length2 sequence, interpret it as ``(vmin, vmax)`` which is used to support setp ACCEPTS: a length 2 sequence of floats'
def set_clim(self, vmin=None, vmax=None):
if ((vmin is not None) and (vmax is None) and cbook.iterable(vmin) and (len(vmin) == 2)): (vmin, vmax) = vmin if (vmin is not None): self.norm.vmin = vmin if (vmax is not None): self.norm.vmax = vmax self.changed()
'set the colormap for luminance data ACCEPTS: a colormap'
def set_cmap(self, cmap):
if (cmap is None): cmap = get_cmap() self.cmap = cmap self.changed()
'set the normalization instance'
def set_norm(self, norm):
if (norm is None): norm = colors.Normalize() self.norm = norm self.changed()
'Autoscale the scalar limits on the norm instance using the current array'
def autoscale(self):
if (self._A is None): raise TypeError('You must first set_array for mappable') self.norm.autoscale(self._A) self.changed()
'Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None'
def autoscale_None(self):
if (self._A is None): raise TypeError('You must first set_array for mappable') self.norm.autoscale_None(self._A) self.changed()
'Add an entry to a dictionary of boolean flags that are set to True when the mappable is changed.'
def add_checker(self, checker):
self.update_dict[checker] = False
'If mappable has changed since the last check, return True; else return False'
def check_update(self, checker):
if self.update_dict[checker]: self.update_dict[checker] = False return True return False
'Call this whenever the mappable is changed to notify all the callbackSM listeners to the \'changed\' signal'
def changed(self):
self.callbacksSM.process('changed', self) for key in self.update_dict: self.update_dict[key] = True
'initialization delayed until first draw; allow time for axes setup.'
def _init(self):
if True: trans = self._set_transform() ax = self.ax (sx, sy) = trans.inverted().transform_point((ax.bbox.width, ax.bbox.height)) self.span = sx sn = max(8, min(25, math.sqrt(self.N))) if (self.width is None): self.width = ((0.06 * self.span) / sn)
'length is in arrow width units'
def _h_arrows(self, length):
minsh = (self.minshaft * self.headlength) N = len(length) length = length.reshape(N, 1) x = np.array([0, (- self.headaxislength), (- self.headlength), 0], np.float64) x = (x + (np.array([0, 1, 1, 1]) * length)) y = (0.5 * np.array([1, 1, self.headwidth, 0], np.float64)) y = np.repeat(y[np.ne...
'Find how many of each of the tail pieces is necessary. Flag specifies the increment for a flag, barb for a full barb, and half for half a barb. Mag should be the magnitude of a vector (ie. >= 0). This returns a tuple of: (*number of flags*, *number of barbs*, *half_flag*, *empty_flag*) *half_flag* is a boolean whethe...
def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50):
if rounding: mag = (half * ((mag / half) + 0.5).astype(np.int)) num_flags = np.floor((mag / flag)).astype(np.int) mag = np.mod(mag, flag) num_barb = np.floor((mag / full)).astype(np.int) mag = np.mod(mag, full) half_flag = (mag >= half) empty_flag = (~ ((half_flag | (num_flags > 0)) ...
'This function actually creates the wind barbs. *u* and *v* are components of the vector in the *x* and *y* directions, respectively. *nflags*, *nbarbs*, and *half_barb*, empty_flag* are, *respectively, the number of flags, number of barbs, flag for *half a barb, and flag for empty barb, ostensibly obtained *from :met...
def _make_barbs(self, u, v, nflags, nbarbs, half_barb, empty_flag, length, pivot, sizes, fill_empty, flip):
spacing = (length * sizes.get('spacing', 0.125)) full_height = (length * sizes.get('height', 0.4)) full_width = (length * sizes.get('width', 0.25)) empty_rad = (length * sizes.get('emptybarb', 0.15)) pivot_points = dict(tip=0.0, middle=((- length) / 2.0)) if flip: full_height = (- full_h...
'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'
def set_offsets(self, xy):
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)
'valid is a list of legal strings'
def __init__(self, key, valid, ignorecase=False):
self.key = key self.ignorecase = ignorecase def func(s): if ignorecase: return s.lower() else: return s self.valid = dict([(func(k), k) for k in valid])
'return a seq of n floats or raise'
def __call__(self, s):
if (type(s) is str): ss = s.split(',') if (len(ss) != self.n): raise ValueError(('You must supply exactly %d comma separated values' % self.n)) try: return [float(val) for val in ss] except ValueError: raise ValueError('Could ...
'return a seq of n ints or raise'
def __call__(self, s):
if (type(s) is str): ss = s.split(',') if (len(ss) != self.n): raise ValueError(('You must supply exactly %d comma separated values' % self.n)) try: return [int(val) for val in ss] except ValueError: raise ValueError('Could ...
'Register a new set of projection(s).'
def register(self, *projections):
for projection in projections: name = projection.name self._all_projection_types[name] = projection
'Get a projection class from its *name*.'
def get_projection_class(self, name):
return self._all_projection_types[name]
'Get a list of the names of all projections currently registered.'
def get_projection_names(self):
names = self._all_projection_types.keys() names.sort() return names
'Create a new polar transform. Resolution is the number of steps to interpolate between each input line segment to approximate its path in curved polar space.'
def __init__(self, resolution):
Transform.__init__(self) self._resolution = resolution
'return a format string formatting the coordinate'
def format_coord(self, long, lat):
long = (long * (180.0 / np.pi)) lat = (lat * (180.0 / np.pi)) if (lat >= 0.0): ns = 'N' else: ns = 'S' if (long >= 0.0): ew = 'E' else: ew = 'W' return (u'%f\xb0%s, %f\xb0%s' % (abs(lat), ns, abs(long), ew))
'Set the number of degrees between each longitude grid.'
def set_longitude_grid(self, degrees):
number = ((360.0 / degrees) + 1) self.xaxis.set_major_locator(FixedLocator(np.linspace((- np.pi), np.pi, number, True)[1:(-1)])) self._logitude_degrees = degrees self.xaxis.set_major_formatter(self.ThetaFormatter(degrees))
'Set the number of degrees between each longitude grid.'
def set_latitude_grid(self, degrees):
number = ((180.0 / degrees) + 1) self.yaxis.set_major_locator(FixedLocator(np.linspace(((- np.pi) / 2.0), (np.pi / 2.0), number, True)[1:(-1)])) self._latitude_degrees = degrees self.yaxis.set_major_formatter(self.ThetaFormatter(degrees))
'Set the latitude(s) at which to stop drawing the longitude grids.'
def set_longitude_grid_ends(self, degrees):
self._longitude_cap = (degrees * (np.pi / 180.0)) self._xaxis_pretransform.clear().scale(1.0, (self._longitude_cap * 2.0)).translate(0.0, (- self._longitude_cap))
'Return the aspect ratio of the data itself.'
def get_data_ratio(self):
return 1.0
'Return True if this axes support the zoom box'
def can_zoom(self):
return False
'Create a new Aitoff transform. Resolution is the number of steps to interpolate between each input line segment to approximate its path in curved Aitoff space.'
def __init__(self, resolution):
Transform.__init__(self) self._resolution = resolution
'Create a new Hammer transform. Resolution is the number of steps to interpolate between each input line segment to approximate its path in curved Hammer space.'
def __init__(self, resolution):
Transform.__init__(self) self._resolution = resolution
'Create a new Mollweide transform. Resolution is the number of steps to interpolate between each input line segment to approximate its path in curved Mollweide space.'
def __init__(self, resolution):
Transform.__init__(self) self._resolution = resolution
'Create a new Lambert transform. Resolution is the number of steps to interpolate between each input line segment to approximate its path in curved Lambert space.'
def __init__(self, center_longitude, center_latitude, resolution):
Transform.__init__(self) self._resolution = resolution self._center_longitude = center_longitude self._center_latitude = center_latitude
'All dimensions are fraction of the figure width or height. All values default to their rc params The following attributes are available *left* = 0.125 the left side of the subplots of the figure *right* = 0.9 the right side of the subplots of the figure *bottom* = 0.1 the bottom of the subplots of the figure *top* = ...
def __init__(self, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None):
self.validate = True self.update(left, bottom, right, top, wspace, hspace)
'Update the current values. If any kwarg is None, default to the current value, if set, otherwise to rc'
def update(self, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None):
thisleft = getattr(self, 'left', None) thisright = getattr(self, 'right', None) thistop = getattr(self, 'top', None) thisbottom = getattr(self, 'bottom', None) thiswspace = getattr(self, 'wspace', None) thishspace = getattr(self, 'hspace', None) self._update_this('left', left) self._upda...
'*figsize* w,h tuple in inches *dpi* dots per inch *facecolor* the figure patch facecolor; defaults to rc ``figure.facecolor`` *edgecolor* the figure patch edge color; defaults to rc ``figure.edgecolor`` *linewidth* the figure patch edge linewidth; the default linewidth of the frame *frameon* if False, suppress drawing...
def __init__(self, figsize=None, dpi=None, facecolor=None, edgecolor=None, linewidth=1.0, frameon=True, subplotpars=None):
Artist.__init__(self) self.callbacks = cbook.CallbackRegistry(('dpi_changed',)) if (figsize is None): figsize = rcParams['figure.figsize'] if (dpi is None): dpi = rcParams['figure.dpi'] if (facecolor is None): facecolor = rcParams['figure.facecolor'] if (edgecolor is None...
'Date ticklabels often overlap, so it is useful to rotate them and right align them. Also, a common use case is a number of subplots with shared xaxes where the x-axis is date data. The ticklabels are often long, and it helps to rotate them on the bottom subplot and turn them off on other subplots, as well as turn of...
def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
allsubplots = np.alltrue([hasattr(ax, 'is_last_row') for ax in self.axes]) if (len(self.axes) == 1): for label in ax.get_xticklabels(): label.set_ha(ha) label.set_rotation(rotation) elif allsubplots: for ax in self.get_axes(): if ax.is_last_row(): ...
'get a list of artists contained in the figure'
def get_children(self):
children = [self.patch] children.extend(self.artists) children.extend(self.axes) children.extend(self.lines) children.extend(self.patches) children.extend(self.texts) children.extend(self.images) children.extend(self.legends) return children
'Test whether the mouse event occurred on the figure. Returns True,{}'
def contains(self, mouseevent):
if callable(self._contains): return self._contains(self, mouseevent) inside = self.bbox.contains(mouseevent.x, mouseevent.y) return (inside, {})
'get the figure bounding box in display space; kwargs are void'
def get_window_extent(self, *args, **kwargs):
return self.bbox
'Add a centered title to the figure. kwargs are :class:`matplotlib.text.Text` properties. Using figure coordinates, the defaults are: - *x* = 0.5 the x location of text in figure coords - *y* = 0.98 the y location of the text in figure coords - *horizontalalignment* = \'center\' the horizontal alignment of the text - ...
def suptitle(self, t, **kwargs):
x = kwargs.pop('x', 0.5) y = kwargs.pop('y', 0.98) if (('horizontalalignment' not in kwargs) and ('ha' not in kwargs)): kwargs['horizontalalignment'] = 'center' if (('verticalalignment' not in kwargs) and ('va' not in kwargs)): kwargs['verticalalignment'] = 'top' t = self.text(x, y, ...
'Set the canvas the contains the figure ACCEPTS: a FigureCanvas instance'
def set_canvas(self, canvas):
self.canvas = canvas
'Set the hold state. If hold is None (default), toggle the hold state. Else set the hold state to boolean value b. Eg:: hold() # toggle hold hold(True) # hold is on hold(False) # hold is off'
def hold(self, b=None):
if (b is None): self._hold = (not self._hold) else: self._hold = b
'call signatures:: figimage(X, **kwargs) adds a non-resampled array *X* to the figure. figimage(X, xo, yo) with pixel offsets *xo*, *yo*, *X* must be a float array: * If *X* is MxN, assume luminance (grayscale) * If *X* is MxNx3, assume RGB * If *X* is MxNx4, assume RGBA Optional keyword arguments: Keyword Descript...
def figimage(self, X, xo=0, yo=0, alpha=1.0, norm=None, cmap=None, vmin=None, vmax=None, origin=None):
if (not self._hold): self.clf() im = FigureImage(self, cmap, norm, xo, yo, origin) im.set_array(X) im.set_alpha(alpha) if (norm is None): im.set_clim(vmin, vmax) self.images.append(im) return im
'set_size_inches(w,h, forward=False) Set the figure size in inches Usage:: fig.set_size_inches(w,h) # OR fig.set_size_inches((w,h) ) optional kwarg *forward=True* will cause the canvas size to be automatically updated; eg you can resize the figure window from the shell WARNING: forward=True is broken on all backends e...
def set_size_inches(self, *args, **kwargs):
forward = kwargs.get('forward', False) if (len(args) == 1): (w, h) = args[0] else: (w, h) = args dpival = self.dpi self.bbox_inches.p1 = (w, h) if forward: dpival = self.dpi canvasw = (w * dpival) canvash = (h * dpival) manager = getattr(self.canva...
'Get the edge color of the Figure rectangle'
def get_edgecolor(self):
return self.patch.get_edgecolor()
'Get the face color of the Figure rectangle'
def get_facecolor(self):
return self.patch.get_facecolor()
'Return the figwidth as a float'
def get_figwidth(self):
return self.bbox_inches.width
'Return the figheight as a float'
def get_figheight(self):
return self.bbox_inches.height
'Return the dpi as a float'
def get_dpi(self):
return self.dpi
'get the boolean indicating frameon'
def get_frameon(self):
return self.frameon
'Set the edge color of the Figure rectangle ACCEPTS: any matplotlib color - see help(colors)'
def set_edgecolor(self, color):
self.patch.set_edgecolor(color)
'Set the face color of the Figure rectangle ACCEPTS: any matplotlib color - see help(colors)'
def set_facecolor(self, color):
self.patch.set_facecolor(color)
'Set the dots-per-inch of the figure ACCEPTS: float'
def set_dpi(self, val):
self.dpi = val
'Set the width of the figure in inches ACCEPTS: float'
def set_figwidth(self, val):
self.bbox_inches.x1 = val
'Set the height of the figure in inches ACCEPTS: float'
def set_figheight(self, val):
self.bbox_inches.y1 = val
'Set whether the figure frame (background) is displayed or invisible ACCEPTS: boolean'
def set_frameon(self, b):
self.frameon = b
'remove a from the figure and update the current axes'
def delaxes(self, a):
self.axes.remove(a) self._axstack.remove(a) keys = [] for (key, thisax) in self._seen.items(): if (a == thisax): del self._seen[key] for func in self._axobservers: func(self)
'make a hashable key out of args and kwargs'
def _make_key(self, *args, **kwargs):
def fixitems(items): ret = [] for (k, v) in items: if iterable(v): v = tuple(v) ret.append((k, v)) return tuple(ret) def fixlist(args): ret = [] for a in args: if iterable(a): a = tuple(a) ret...
'Add an a axes with axes rect [*left*, *bottom*, *width*, *height*] where all quantities are in fractions of figure width and height. kwargs are legal :class:`~matplotlib.axes.Axes` kwargs plus *projection* which sets the projection type of the axes. (For backward compatibility, ``polar=True`` may also be provided, w...
def add_axes(self, *args, **kwargs):
key = self._make_key(*args, **kwargs) if (key in self._seen): ax = self._seen[key] self.sca(ax) return ax if (not len(args)): return if isinstance(args[0], Axes): a = args[0] assert (a.get_figure() is self) else: rect = args[0] ispolar ...
'Add a subplot. Examples: fig.add_subplot(111) fig.add_subplot(1,1,1) # equivalent but more general fig.add_subplot(212, axisbg=\'r\') # add subplot with red background fig.add_subplot(111, polar=True) # add a polar subplot fig.add_subplot(sub) # add Subplot instance sub *kwargs* are legal :c...
def add_subplot(self, *args, **kwargs):
kwargs = kwargs.copy() if (not len(args)): return if isinstance(args[0], SubplotBase): a = args[0] assert (a.get_figure() is self) else: ispolar = kwargs.pop('polar', False) projection = kwargs.pop('projection', None) if ispolar: if ((projectio...
'Clear the figure'
def clf(self):
self.suppressComposite = None self.callbacks = cbook.CallbackRegistry(('dpi_changed',)) for ax in tuple(self.axes): ax.cla() self.delaxes(ax) toolbar = getattr(self.canvas, 'toolbar', None) if (toolbar is not None): toolbar.update() self._axstack.clear() self._seen = ...
'Clear the figure -- synonym for fig.clf'
def clear(self):
self.clf()
'Render the figure using :class:`matplotlib.backend_bases.RendererBase` instance renderer'
def draw(self, renderer):
if (not self.get_visible()): return renderer.open_group('figure') if self.frameon: self.patch.draw(renderer) for p in self.patches: p.draw(renderer) for l in self.lines: l.draw(renderer) for a in self.artists: a.draw(renderer) composite = renderer.opti...
'draw :class:`matplotlib.artist.Artist` instance *a* only -- this is available only after the figure is drawn'
def draw_artist(self, a):
assert (self._cachedRenderer is not None) a.draw(self._cachedRenderer)
'Place a legend in the figure. Labels are a sequence of strings, handles is a sequence of :class:`~matplotlib.lines.Line2D` or :class:`~matplotlib.patches.Patch` instances, and loc can be a string or an integer specifying the legend location USAGE:: legend( (line1, line2, line3), (\'label1\', \'label2\', \'label3\'), ...
def legend(self, handles, labels, *args, **kwargs):
handles = flatten(handles) l = Legend(self, handles, labels, *args, **kwargs) self.legends.append(l) return l
'Call signature:: figtext(x, y, s, fontdict=None, **kwargs) Add text to figure at location *x*, *y* (relative 0-1 coords). See :func:`~matplotlib.pyplot.text` for the meaning of the other arguments. kwargs control the :class:`~matplotlib.text.Text` properties: %(Text)s'
def text(self, x, y, s, *args, **kwargs):
override = _process_text_args({}, *args, **kwargs) t = Text(x=x, y=y, text=s) t.update(override) self._set_artist_props(t) self.texts.append(t) return t
'Return the current axes, creating one if necessary The following kwargs are supported %(Axes)s'
def gca(self, **kwargs):
ax = self._axstack() if (ax is not None): ispolar = kwargs.get('polar', False) projection = kwargs.get('projection', None) if ispolar: if ((projection is not None) and (projection != 'polar')): raise ValueError(("polar=True, yet projection='%s'. " + (...
'Set the current axes to be a and return a'
def sca(self, a):
self._axstack.bubble(a) for func in self._axobservers: func(self) return a
'whenever the axes state change, func(self) will be called'
def add_axobserver(self, func):
self._axobservers.append(func)
'call signature:: savefig(fname, dpi=None, facecolor=\'w\', edgecolor=\'w\', orientation=\'portrait\', papertype=None, format=None, transparent=False): Save the current figure. The output formats available depend on the backend being used. Arguments: *fname*: A string containing a path to a filename, or a Python file-l...
def savefig(self, *args, **kwargs):
for key in ('dpi', 'facecolor', 'edgecolor'): if (key not in kwargs): kwargs[key] = rcParams[('savefig.%s' % key)] transparent = kwargs.pop('transparent', False) if transparent: original_figure_alpha = self.patch.get_alpha() self.patch.set_alpha(0.0) original_axes...
'fig.subplots_adjust(left=None, bottom=None, right=None, wspace=None, hspace=None) Update the :class:`SubplotParams` with *kwargs* (defaulting to rc where None) and update the subplot locations'
def subplots_adjust(self, *args, **kwargs):
self.subplotpars.update(*args, **kwargs) import matplotlib.axes for ax in self.axes: if (not isinstance(ax, matplotlib.axes.SubplotBase)): if ((ax._sharex is not None) and isinstance(ax._sharex, matplotlib.axes.SubplotBase)): ax._sharex.update_params() ax....
'call signature:: ginput(self, n=1, timeout=30, show_clicks=True) Blocking call to interact with the figure. This will wait for *n* clicks from the user and return a list of the coordinates of each click. If *timeout* is zero or negative, does not timeout. If *n* is zero or negative, accumulate clicks until a middle cl...
def ginput(self, n=1, timeout=30, show_clicks=True):
blocking_mouse_input = BlockingMouseInput(self) return blocking_mouse_input(n=n, timeout=timeout, show_clicks=show_clicks)
'call signature:: waitforbuttonpress(self, timeout=-1) Blocking call to interact with the figure. This will return True is a key was pressed, False if a mouse button was pressed and None if *timeout* was reached without either being pressed. If *timeout* is negative, does not timeout.'
def waitforbuttonpress(self, timeout=(-1)):
blocking_input = BlockingKeyMouseInput(self) return blocking_input(timeout=timeout)
'Create a :class:`~matplotlib.text.Text` instance at *x*, *y* with string *text*. Valid kwargs are %(Text)s'
def __init__(self, x=0, y=0, text='', color=None, verticalalignment='bottom', horizontalalignment='left', multialignment=None, fontproperties=None, rotation=None, linespacing=None, **kwargs):
Artist.__init__(self) self.cached = maxdict(5) (self._x, self._y) = (x, y) if (color is None): color = rcParams['text.color'] if (fontproperties is None): fontproperties = FontProperties() elif is_string_like(fontproperties): fontproperties = FontProperties(fontproperties...
'Test whether the mouse event occurred in the patch. In the case of text, a hit is true anywhere in the axis-aligned bounding-box containing the text. Returns True or False.'
def contains(self, mouseevent):
if callable(self._contains): return self._contains(self, mouseevent) if ((not self.get_visible()) or (self._renderer is None)): return (False, {}) (l, b, w, h) = self.get_window_extent().bounds r = (l + w) t = (b + h) xyverts = ((l, b), (l, t), (r, t), (r, b)) (x, y) = (mouse...
'get the (possibly unit converted) transformed x, y in display coords'
def _get_xy_display(self):
(x, y) = self.get_position() return self.get_transform().transform_point((x, y))
'return the text angle as float in degrees'
def get_rotation(self):
return get_rotation(self._rotation)
'Copy properties from other to self'
def update_from(self, other):
Artist.update_from(self, other) self._color = other._color self._multialignment = other._multialignment self._verticalalignment = other._verticalalignment self._horizontalalignment = other._horizontalalignment self._fontproperties = other._fontproperties.copy() self._rotation = other._rotati...
'Draw a bounding box around self. rectprops are any settable properties for a rectangle, eg facecolor=\'red\', alpha=0.5. t.set_bbox(dict(facecolor=\'red\', alpha=0.5)) If rectprops has "boxstyle" key. A FancyBboxPatch is initialized with rectprops and will be drawn. The mutation scale of the FancyBboxPath is set to t...
def set_bbox(self, rectprops):
if ((rectprops is not None) and ('boxstyle' in rectprops)): props = rectprops.copy() boxstyle = props.pop('boxstyle') bbox_transmuter = props.pop('bbox_transmuter', None) self._bbox_patch = FancyBboxPatch((0.0, 0.0), 1.0, 1.0, boxstyle=boxstyle, bbox_transmuter=bbox_transmuter, trans...
'Return the bbox Patch object. Returns None if the the FancyBboxPatch is not made.'
def get_bbox_patch(self):
return self._bbox_patch
'Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox.'
def update_bbox_position_size(self, renderer):
if (not isinstance(self.arrow_patch, FancyArrowPatch)): return if self._bbox_patch: trans = self.get_transform() posx = float(self.convert_xunits(self._x)) posy = float(self.convert_yunits(self._y)) (posx, posy) = trans.transform_point((posx, posy)) (x_box, y_box,...
'Update the location and the size of the bbox (FancyBoxPatch), and draw'
def _draw_bbox(self, renderer, posx, posy):
(x_box, y_box, w_box, h_box) = _get_textbox(self, renderer) self._bbox_patch.set_bounds(0.0, 0.0, w_box, h_box) theta = ((self.get_rotation() / 180.0) * math.pi) tr = mtransforms.Affine2D().rotate(theta) tr = tr.translate((posx + x_box), (posy + y_box)) self._bbox_patch.set_transform(tr) fon...
'Draws the :class:`Text` object to the given *renderer*.'
def draw(self, renderer):
if (renderer is not None): self._renderer = renderer if (not self.get_visible()): return if (self._text == ''): return (bbox, info) = self._get_layout(renderer) trans = self.get_transform() posx = float(self.convert_xunits(self._x)) posy = float(self.convert_yunits(se...
'Return the color of the text'
def get_color(self):
return self._color
'Return the :class:`~font_manager.FontProperties` object'
def get_fontproperties(self):
return self._fontproperties
'alias for get_fontproperties'
def get_font_properties(self):
return self.get_fontproperties
'Return the list of font families used for font lookup'
def get_family(self):
return self._fontproperties.get_family()
'alias for get_family'
def get_fontfamily(self):
return self.get_family()
'Return the font name as string'
def get_name(self):
return self._fontproperties.get_name()
'Return the font style as string'
def get_style(self):
return self._fontproperties.get_style()
'Return the font size as integer'
def get_size(self):
return self._fontproperties.get_size_in_points()
'Return the font variant as a string'
def get_variant(self):
return self._fontproperties.get_variant()
'alias for get_variant'
def get_fontvariant(self):
return self.get_variant()
'Get the font weight as string or number'
def get_weight(self):
return self._fontproperties.get_weight()
'alias for get_name'
def get_fontname(self):
return self.get_name()