desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'call signature::
bar(left, height, width=0.8, bottom=0,
color=None, edgecolor=None, linewidth=None,
yerr=None, xerr=None, ecolor=None, capsize=3,
align=\'edge\', orientation=\'vertical\', log=False)
Make a bar plot with rectangles bounded by:
*left*, *left* + *width*, *bottom*, *bottom* + *height*
(left, right, bottom... | def bar(self, left, height, width=0.8, bottom=None, color=None, edgecolor=None, linewidth=None, yerr=None, xerr=None, ecolor=None, capsize=3, align='edge', orientation='vertical', log=False, **kwargs):
| if (not self._hold):
self.cla()
label = kwargs.pop('label', '')
def make_iterable(x):
if (not iterable(x)):
return [x]
else:
return x
_left = left
left = make_iterable(left)
height = make_iterable(height)
width = make_iterable(width)
_botto... |
'call signature::
barh(bottom, width, height=0.8, left=0, **kwargs)
Make a horizontal bar plot with rectangles bounded by:
*left*, *left* + *width*, *bottom*, *bottom* + *height*
(left, right, bottom and top edges)
*bottom*, *width*, *height*, and *left* can be either scalars
or sequences
Return value is a list of
:cla... | def barh(self, bottom, width, height=0.8, left=None, **kwargs):
| patches = self.bar(left=left, height=height, width=width, bottom=bottom, orientation='horizontal', **kwargs)
return patches
|
'call signature::
broken_barh(self, xranges, yrange, **kwargs)
A collection of horizontal bars spanning *yrange* with a sequence of
*xranges*.
Required arguments:
Argument Description
*xranges* sequence of (*xmin*, *xwidth*)
*yrange* sequence of (*ymin*, *ywidth*)
kwargs are
:class:`matplotlib.collections.Broke... | def broken_barh(self, xranges, yrange, **kwargs):
| col = mcoll.BrokenBarHCollection(xranges, yrange, **kwargs)
self.add_collection(col, autolim=True)
self.autoscale_view()
return col
|
'call signature::
stem(x, y, linefmt=\'b-\', markerfmt=\'bo\', basefmt=\'r-\')
A stem plot plots vertical lines (using *linefmt*) at each *x*
location from the baseline to *y*, and places a marker there
using *markerfmt*. A horizontal line at 0 is is plotted using
*basefmt*.
Return value is a tuple (*markerline*, *ste... | def stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-'):
| remember_hold = self._hold
if (not self._hold):
self.cla()
self.hold(True)
(markerline,) = self.plot(x, y, markerfmt)
stemlines = []
for (thisx, thisy) in zip(x, y):
(l,) = self.plot([thisx, thisx], [0, thisy], linefmt)
stemlines.append(l)
(baseline,) = self.plot([np.... |
'call signature::
pie(x, explode=None, labels=None,
colors=(\'b\', \'g\', \'r\', \'c\', \'m\', \'y\', \'k\', \'w\'),
autopct=None, pctdistance=0.6, labeldistance=1.1, shadow=False)
Make a pie chart of array *x*. The fractional area of each
wedge is given by x/sum(x). If sum(x) <= 1, then the values
of x give the frac... | def pie(self, x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1):
| self.set_frame_on(False)
x = np.asarray(x).astype(np.float32)
sx = float(x.sum())
if (sx > 1):
x = np.divide(x, sx)
if (labels is None):
labels = ([''] * len(x))
if (explode is None):
explode = ([0] * len(x))
assert (len(x) == len(labels))
assert (len(x) == len(ex... |
'call signature::
errorbar(x, y, yerr=None, xerr=None,
fmt=\'-\', ecolor=None, elinewidth=None, capsize=3,
barsabove=False, lolims=False, uplims=False,
xlolims=False, xuplims=False)
Plot *x* versus *y* with error deltas in *yerr* and *xerr*.
Vertical errorbars are plotted if *yerr* is not *None*.
Horizontal errorbars a... | def errorbar(self, x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None, capsize=3, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, **kwargs):
| self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
if (not self._hold):
self.cla()
if (not iterable(x)):
x = [x]
if (not iterable(y)):
y = [y]
if (xerr is not None):
if (not iterable(xerr)):
xerr = ([xerr] * len(x))
if (yerr is not None):
... |
'call signature::
boxplot(x, notch=0, sym=\'+\', vert=1, whis=1.5,
positions=None, widths=None)
Make a box and whisker plot for each column of *x* or each
vector in sequence *x*. The box extends from the lower to
upper quartile values of the data, with a line at the median.
The whiskers extend from the box to show the... | def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5, positions=None, widths=None):
| if (not self._hold):
self.cla()
holdStatus = self._hold
(whiskers, caps, boxes, medians, fliers) = ([], [], [], [], [])
if hasattr(x, 'shape'):
if (len(x.shape) == 1):
if hasattr(x[0], 'shape'):
x = list(x)
else:
x = [x]
eli... |
'call signatures::
scatter(x, y, s=20, c=\'b\', marker=\'o\', cmap=None, norm=None,
vmin=None, vmax=None, alpha=1.0, linewidths=None,
verts=None, **kwargs)
Make a scatter plot of *x* versus *y*, where *x*, *y* are 1-D
sequences of the same length, *N*.
Keyword arguments:
*s*:
size in points^2. It is a scalar or an arr... | def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, linewidths=None, faceted=True, verts=None, **kwargs):
| if (not self._hold):
self.cla()
syms = {'s': (4, (math.pi / 4.0), 0), 'o': (20, 3, 0), '^': (3, 0, 0), '>': (3, (math.pi / 2.0), 0), 'v': (3, math.pi, 0), '<': (3, ((3 * math.pi) / 2.0), 0), 'd': (4, 0, 0), 'p': (5, 0, 0), 'h': (6, 0, 0), '8': (8, 0, 0), '+': (4, 0, 2), 'x': (4, (math.pi / 4.0), 2)}
... |
'call signature::
hexbin(x, y, C = None, gridsize = 100, bins = None,
xscale = \'linear\', yscale = \'linear\',
cmap=None, norm=None, vmin=None, vmax=None,
alpha=1.0, linewidths=None, edgecolors=\'none\'
reduce_C_function = np.mean,
**kwargs)
Make a hexagonal binning plot of *x* versus *y*, where *x*,
*y* are 1-D seque... | def hexbin(self, x, y, C=None, gridsize=100, bins=None, xscale='linear', yscale='linear', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, linewidths=None, edgecolors='none', reduce_C_function=np.mean, **kwargs):
| if (not self._hold):
self.cla()
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
(x, y, C) = cbook.delete_masked_points(x, y, C)
if iterable(gridsize):
(nx, ny) = gridsize
else:
nx = gridsize
ny = int((nx / math.sqrt(3)))
x = np.array(x, float)
y = np.... |
'call signature::
arrow(x, y, dx, dy, **kwargs)
Draws arrow on specified axis from (*x*, *y*) to (*x* + *dx*,
*y* + *dy*).
Optional kwargs control the arrow properties:
%(FancyArrow)s
**Example:**
.. plot:: mpl_examples/pylab_examples/arrow_demo.py'
| def arrow(self, x, y, dx, dy, **kwargs):
| a = mpatches.FancyArrow(x, y, dx, dy, **kwargs)
self.add_artist(a)
return a
|
'%(barbs_doc)s
**Example:**
.. plot:: mpl_examples/pylab_examples/barb_demo.py'
| def barbs(self, *args, **kw):
| if (not self._hold):
self.cla()
b = mquiver.Barbs(self, *args, **kw)
self.add_collection(b)
self.update_datalim(b.get_offsets())
self.autoscale_view()
return b
|
'call signature::
fill(*args, **kwargs)
Plot filled polygons. *args* is a variable length argument,
allowing for multiple *x*, *y* pairs with an optional color
format string; see :func:`~matplotlib.pyplot.plot` for details
on the argument parsing. For example, to plot a polygon with
vertices at *x*, *y* in blue.::
ax... | def fill(self, *args, **kwargs):
| if (not self._hold):
self.cla()
patches = []
for poly in self._get_patches_for_fill(*args, **kwargs):
self.add_patch(poly)
patches.append(poly)
self.autoscale_view()
return patches
|
'call signature::
fill_between(x, y1, y2=0, where=None, **kwargs)
Create a :class:`~matplotlib.collections.PolyCollection`
filling the regions between *y1* and *y2* where
``where==True``
*x*
an N length np array of the x data
*y1*
an N length scalar or np array of the x data
*y2*
an N length scalar or np array of the x... | def fill_between(self, x, y1, y2=0, where=None, **kwargs):
| self._process_unit_info(xdata=x, ydata=y1, kwargs=kwargs)
self._process_unit_info(ydata=y2)
x = np.asarray(self.convert_xunits(x))
y1 = np.asarray(self.convert_yunits(y1))
y2 = np.asarray(self.convert_yunits(y2))
if (not cbook.iterable(y1)):
y1 = (np.ones_like(x) * y1)
if (not cbook.... |
'call signature::
imshow(X, cmap=None, norm=None, aspect=None, interpolation=None,
alpha=1.0, vmin=None, vmax=None, origin=None, extent=None,
**kwargs)
Display the image in *X* to current axes. *X* may be a float
array, a uint8 array or a PIL image. If *X* is an array, *X*
can have the following shapes:
* MxN -- lumin... | def imshow(self, X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=1.0, vmin=None, vmax=None, origin=None, extent=None, shape=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, **kwargs):
| if (not self._hold):
self.cla()
if (norm is not None):
assert isinstance(norm, mcolors.Normalize)
if (cmap is not None):
assert isinstance(cmap, mcolors.Colormap)
if (aspect is None):
aspect = rcParams['image.aspect']
self.set_aspect(aspect)
im = mimage.AxesImage(... |
'call signatures::
pcolor(C, **kwargs)
pcolor(X, Y, C, **kwargs)
Create a pseudocolor plot of a 2-D array.
*C* is the array of color values.
*X* and *Y*, if given, specify the (*x*, *y*) coordinates of
the colored quadrilaterals; the quadrilateral for C[i,j] has
corners at::
(X[i, j], Y[i, j]),
(X[i, j+1], Y[i,... | def pcolor(self, *args, **kwargs):
| if (not self._hold):
self.cla()
alpha = kwargs.pop('alpha', 1.0)
norm = kwargs.pop('norm', None)
cmap = kwargs.pop('cmap', None)
vmin = kwargs.pop('vmin', None)
vmax = kwargs.pop('vmax', None)
shading = kwargs.pop('shading', 'flat')
(X, Y, C) = self._pcolorargs('pcolor', *args)
... |
'call signatures::
pcolormesh(C)
pcolormesh(X, Y, C)
pcolormesh(C, **kwargs)
*C* may be a masked array, but *X* and *Y* may not. Masked
array support is implemented via *cmap* and *norm*; in
contrast, :func:`~matplotlib.pyplot.pcolor` simply does not
draw quadrilaterals with masked colors or vertices.
Keyword argument... | def pcolormesh(self, *args, **kwargs):
| if (not self._hold):
self.cla()
alpha = kwargs.pop('alpha', 1.0)
norm = kwargs.pop('norm', None)
cmap = kwargs.pop('cmap', None)
vmin = kwargs.pop('vmin', None)
vmax = kwargs.pop('vmax', None)
shading = kwargs.pop('shading', 'flat')
edgecolors = kwargs.pop('edgecolors', 'None')
... |
'pseudocolor plot of a 2-D array
Experimental; this is a version of pcolor that
does not draw lines, that provides the fastest
possible rendering with the Agg backend, and that
can handle any quadrilateral grid.
Call signatures::
pcolor(C, **kwargs)
pcolor(xr, yr, C, **kwargs)
pcolor(x, y, C, **kwargs)
pcolor(X, Y, C, ... | def pcolorfast(self, *args, **kwargs):
| if (not self._hold):
self.cla()
alpha = kwargs.pop('alpha', 1.0)
norm = kwargs.pop('norm', None)
cmap = kwargs.pop('cmap', None)
vmin = kwargs.pop('vmin', None)
vmax = kwargs.pop('vmax', None)
if (norm is not None):
assert isinstance(norm, mcolors.Normalize)
if (cmap is n... |
'call signature::
table(cellText=None, cellColours=None,
cellLoc=\'right\', colWidths=None,
rowLabels=None, rowColours=None, rowLoc=\'left\',
colLabels=None, colColours=None, colLoc=\'center\',
loc=\'bottom\', bbox=None):
Add a table to the current axes. Returns a
:class:`matplotlib.table.Table` instance. For finer g... | def table(self, **kwargs):
| return mtable.table(self, **kwargs)
|
'call signature::
ax = twinx()
create a twin of Axes for generating a plot with a sharex
x-axis but independent y axis. The y-axis of self will have
ticks on left and the returned axes will have ticks on the
right'
| def twinx(self):
| ax2 = self.figure.add_axes(self.get_position(True), sharex=self, frameon=False)
ax2.yaxis.tick_right()
ax2.yaxis.set_label_position('right')
self.yaxis.tick_left()
return ax2
|
'call signature::
ax = twiny()
create a twin of Axes for generating a plot with a shared
y-axis but independent x axis. The x-axis of self will have
ticks on bottom and the returned axes will have ticks on the
top'
| def twiny(self):
| ax2 = self.figure.add_axes(self.get_position(True), sharey=self, frameon=False)
ax2.xaxis.tick_top()
ax2.xaxis.set_label_position('top')
self.xaxis.tick_bottom()
return ax2
|
'Return a copy of the shared axes Grouper object for x axes'
| def get_shared_x_axes(self):
| return self._shared_x_axes
|
'Return a copy of the shared axes Grouper object for y axes'
| def get_shared_y_axes(self):
| return self._shared_y_axes
|
'call signature::
hist(x, bins=10, range=None, normed=False, cumulative=False,
bottom=None, histtype=\'bar\', align=\'mid\',
orientation=\'vertical\', rwidth=None, log=False, **kwargs)
Compute and draw the histogram of *x*. The return value is a
tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,
[*patches0*,... | def hist(self, x, bins=10, range=None, normed=False, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, **kwargs):
| if (not self._hold):
self.cla()
if (kwargs.get('width') is not None):
raise DeprecationWarning('hist now uses the rwidth to give relative width and not absolute width')
try:
x = np.transpose(np.array(x))
if (len(x.shape) == 1):
... |
'call signature::
psd(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, pad_to=None,
sides=\'default\', scale_by_freq=None, **kwargs)
The power spectral density by Welch\'s average periodogram
method. The vector *x* is divided into *NFFT* length
segments. Each segment is detr... | def psd(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, **kwargs):
| if (not self._hold):
self.cla()
(pxx, freqs) = mlab.psd(x, NFFT, Fs, detrend, window, noverlap, pad_to, sides, scale_by_freq)
pxx.shape = (len(freqs),)
freqs += Fc
if (scale_by_freq in (None, True)):
psd_units = 'dB/Hz'
else:
psd_units = 'dB'
self.plot(freqs, (10 * np... |
'call signature::
csd(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=0, pad_to=None,
sides=\'default\', scale_by_freq=None, **kwargs)
The cross spectral density :math:`P_{xy}` by Welch\'s average
periodogram method. The vectors *x* and *y* are divided into
*NFFT* length seg... | def csd(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, **kwargs):
| if (not self._hold):
self.cla()
(pxy, freqs) = mlab.csd(x, y, NFFT, Fs, detrend, window, noverlap, pad_to, sides, scale_by_freq)
pxy.shape = (len(freqs),)
freqs += Fc
self.plot(freqs, (10 * np.log10(np.absolute(pxy))), **kwargs)
self.set_xlabel('Frequency')
self.set_ylabel('Cross ... |
'call signature::
cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
window = mlab.window_hanning, noverlap=0, pad_to=None,
sides=\'default\', scale_by_freq=None, **kwargs)
cohere the coherence between *x* and *y*. Coherence is the normalized
cross spectral density:
.. math::
C_{xy} = \frac{|P_{xy}|^2}{P_... | def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, **kwargs):
| if (not self._hold):
self.cla()
(cxy, freqs) = mlab.cohere(x, y, NFFT, Fs, detrend, window, noverlap, scale_by_freq)
freqs += Fc
self.plot(freqs, cxy, **kwargs)
self.set_xlabel('Frequency')
self.set_ylabel('Coherence')
self.grid(True)
return (cxy, freqs)
|
'call signature::
specgram(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
window=mlab.window_hanning, noverlap=128,
cmap=None, xextent=None, pad_to=None, sides=\'default\',
scale_by_freq=None)
Compute a spectrogram of data in *x*. Data are split into
*NFFT* length segments and the PSD of each section is
computed.... | def specgram(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=128, cmap=None, xextent=None, pad_to=None, sides='default', scale_by_freq=None):
| if (not self._hold):
self.cla()
(Pxx, freqs, bins) = mlab.specgram(x, NFFT, Fs, detrend, window, noverlap, pad_to, sides, scale_by_freq)
Z = (10.0 * np.log10(Pxx))
Z = np.flipud(Z)
if (xextent is None):
xextent = (0, np.amax(bins))
(xmin, xmax) = xextent
freqs += Fc
exten... |
'call signature::
spy(Z, precision=0, marker=None, markersize=None,
aspect=\'equal\', **kwargs)
``spy(Z)`` plots the sparsity pattern of the 2-D array *Z*.
If *precision* is 0, any non-zero value will be plotted;
else, values of :math:`|Z| > precision` will be plotted.
For :class:`scipy.sparse.spmatrix` instances, ther... | def spy(self, Z, precision=0, marker=None, markersize=None, aspect='equal', **kwargs):
| if (precision is None):
precision = 0
warnings.DeprecationWarning('Use precision=0 instead of None')
if ((marker is None) and (markersize is None) and hasattr(Z, 'tocoo')):
marker = 's'
if ((marker is None) and (markersize is None)):
Z = np.asarray(Z)
mask... |
'Plot a matrix or array as an image.
The matrix will be shown the way it would be printed,
with the first row at the top. Row and column numbering
is zero-based.
Argument:
*Z* anything that can be interpreted as a 2-D array
kwargs all are passed to :meth:`~matplotlib.axes.Axes.imshow`.
:meth:`matshow` sets defaults ... | def matshow(self, Z, **kwargs):
| Z = np.asarray(Z)
(nr, nc) = Z.shape
extent = [(-0.5), (nc - 0.5), (nr - 0.5), (-0.5)]
kw = {'extent': extent, 'origin': 'upper', 'interpolation': 'nearest', 'aspect': 'equal'}
kw.update(kwargs)
im = self.imshow(Z, **kw)
self.title.set_y(1.05)
self.xaxis.tick_top()
self.xaxis.set_tic... |
'*fig* is a :class:`matplotlib.figure.Figure` instance.
*args* is the tuple (*numRows*, *numCols*, *plotNum*), where
the array of subplots in the figure has dimensions *numRows*,
*numCols*, and where *plotNum* is the number of the subplot
being created. *plotNum* starts at 1 in the upper left
corner and increases to t... | def __init__(self, fig, *args, **kwargs):
| self.figure = fig
if (len(args) == 1):
s = str(args[0])
if (len(s) != 3):
raise ValueError('Argument to subplot must be a 3 digits long')
(rows, cols, num) = map(int, s)
elif (len(args) == 3):
(rows, cols, num) = args
else:
rais... |
'get the subplot geometry, eg 2,2,3'
| def get_geometry(self):
| return (self._rows, self._cols, (self._num + 1))
|
'change subplot geometry, eg. from 1,1,1 to 2,2,3'
| def change_geometry(self, numrows, numcols, num):
| self._rows = numrows
self._cols = numcols
self._num = (num - 1)
self.update_params()
self.set_position(self.figbox)
|
'update the subplot position from fig.subplotpars'
| def update_params(self):
| rows = self._rows
cols = self._cols
num = self._num
pars = self.figure.subplotpars
left = pars.left
right = pars.right
bottom = pars.bottom
top = pars.top
wspace = pars.wspace
hspace = pars.hspace
totWidth = (right - left)
totHeight = (top - bottom)
figH = (totHeight ... |
'set the visible property on ticklabels so xticklabels are
visible only if the subplot is in the last row and yticklabels
are visible only if the subplot is in the first column'
| def label_outer(self):
| lastrow = self.is_last_row()
firstcol = self.is_first_col()
for label in self.get_xticklabels():
label.set_visible(lastrow)
for label in self.get_yticklabels():
label.set_visible(firstcol)
|
'Initialize the object. This takes the filename as input and
opens the file; actually reading the file happens when
iterating through the pages of the file.'
| def __init__(self, filename, dpi):
| matplotlib.verbose.report(('Dvi: ' + filename), 'debug')
self.file = open(filename, 'rb')
self.dpi = dpi
self.fonts = {}
self.state = _dvistate.pre
|
'Iterate through the pages of the file.
Returns (text, pages) pairs, where:
text is a list of (x, y, fontnum, glyphnum, width) tuples
boxes is a list of (x, y, height, width) tuples
The coordinates are transformed into a standard Cartesian
coordinate system at the dpi value given when initializing.
The coordinates are ... | def __iter__(self):
| while True:
have_page = self._read()
if have_page:
(yield self._output())
else:
break
|
'Close the underlying file if it is open.'
| def close(self):
| if (not self.file.closed):
self.file.close()
|
'Output the text and boxes belonging to the most recent page.
page = dvi._output()'
| def _output(self):
| (minx, miny, maxx, maxy) = (np.inf, np.inf, (- np.inf), (- np.inf))
maxy_pure = (- np.inf)
for elt in (self.text + self.boxes):
if (len(elt) == 4):
(x, y, h, w) = elt
e = 0
else:
(x, y, font, g, w) = elt
h = _mul2012(font._scale, font._tfm.heig... |
'Read one page from the file. Return True if successful,
False if there were no more pages.'
| def _read(self):
| while True:
byte = ord(self.file.read(1))
self._dispatch(byte)
if (byte == 140):
return True
if (self.state == _dvistate.post_post):
self.close()
return False
|
'Read and return an integer argument "nbytes" long.
Signedness is determined by the "signed" keyword.'
| def _arg(self, nbytes, signed=False):
| str = self.file.read(nbytes)
value = ord(str[0])
if (signed and (value >= 128)):
value = (value - 256)
for i in range(1, nbytes):
value = ((256 * value) + ord(str[i]))
return value
|
'Based on the opcode "byte", read the correct kinds of
arguments from the dvi file and call the method implementing
that opcode with those arguments.'
| def _dispatch(self, byte):
| if (0 <= byte <= 127):
self._set_char(byte)
elif (byte == 128):
self._set_char(self._arg(1))
elif (byte == 129):
self._set_char(self._arg(2))
elif (byte == 130):
self._set_char(self._arg(3))
elif (byte == 131):
self._set_char(self._arg(4, True))
elif (byte... |
'Width of char in dvi units. For internal use by dviread.py.'
| def _width_of(self, char):
| width = self._tfm.width.get(char, None)
if (width is not None):
return _mul2012(width, self._scale)
matplotlib.verbose.report(('No width for char %d in font %s' % (char, self.texname)), 'debug')
return 0
|
'Parse each line into words.'
| def _parse(self, file):
| for line in file:
line = line.strip()
if ((line == '') or line.startswith('%')):
continue
(words, pos) = ([], 0)
while (pos < len(line)):
if (line[pos] == '"'):
pos += 1
end = line.index('"', pos)
words.append(li... |
'Register a font described by "words".
The format is, AFAIK: texname fontname [effects and filenames]
Effects are PostScript snippets like ".177 SlantFont",
filenames begin with one or two less-than signs. A filename
ending in enc is an encoding file, other filenames are font
files. This can be overridden with a left b... | def _register(self, words):
| (texname, psname) = words[:2]
(effects, encoding, filename) = ([], None, None)
for word in words[2:]:
if (not word.startswith('<')):
effects.append(word)
else:
word = word.lstrip('<')
if word.startswith('['):
assert (encoding is None)
... |
'Create a Collection
%(Collection)s'
| def __init__(self, edgecolors=None, facecolors=None, linewidths=None, linestyles='solid', antialiaseds=None, offsets=None, transOffset=None, norm=None, cmap=None, pickradius=5.0, urls=None, **kwargs):
| artist.Artist.__init__(self)
cm.ScalarMappable.__init__(self, norm, cmap)
self.set_edgecolor(edgecolors)
self.set_facecolor(facecolors)
self.set_linewidth(linewidths)
self.set_linestyle(linestyles)
self.set_antialiased(antialiaseds)
self.set_urls(urls)
self._uniform_offsets = None
... |
'Point prep for drawing and hit testing'
| def _prepare_points(self):
| transform = self.get_transform()
transOffset = self._transOffset
offsets = self._offsets
paths = self.get_paths()
if self.have_units():
paths = []
for path in self.get_paths():
vertices = path.vertices
(xs, ys) = (vertices[:, 0], vertices[:, 1])
xs... |
'Test whether the mouse event occurred in the collection.
Returns True | False, ``dict(ind=itemlist)``, where every
item in itemlist contains the event.'
| def contains(self, mouseevent):
| if callable(self._contains):
return self._contains(self, mouseevent)
if (not self.get_visible()):
return (False, {})
(transform, transOffset, offsets, paths) = self._prepare_points()
ind = mpath.point_in_path_collection(mouseevent.x, mouseevent.y, self._pickradius, transform.frozen(), pa... |
'Set the offsets for the collection. *offsets* can be a scalar
or a sequence.
ACCEPTS: float or sequence of floats'
| def set_offsets(self, offsets):
| offsets = np.asarray(offsets, np.float_)
if (len(offsets.shape) == 1):
offsets = offsets[np.newaxis, :]
if (self._uniform_offsets is None):
self._offsets = offsets
else:
self._uniform_offsets = offsets
|
'Return the offsets for the collection.'
| def get_offsets(self):
| if (self._uniform_offsets is None):
return self._offsets
else:
return self._uniform_offsets
|
'Set the linewidth(s) for the collection. *lw* can be a scalar
or a sequence; if it is a sequence the patches will cycle
through the sequence
ACCEPTS: float or sequence of floats'
| def set_linewidth(self, lw):
| if (lw is None):
lw = mpl.rcParams['patch.linewidth']
self._linewidths = self._get_value(lw)
|
'alias for set_linewidth'
| def set_linewidths(self, lw):
| return self.set_linewidth(lw)
|
'alias for set_linewidth'
| def set_lw(self, lw):
| return self.set_linewidth(lw)
|
'Set the linestyle(s) for the collection.
ACCEPTS: [\'solid\' | \'dashed\', \'dashdot\', \'dotted\' |
(offset, on-off-dash-seq) ]'
| def set_linestyle(self, ls):
| try:
dashd = backend_bases.GraphicsContextBase.dashd
if cbook.is_string_like(ls):
if (ls in dashd):
dashes = [dashd[ls]]
elif (ls in cbook.ls_mapper):
dashes = [dashd[cbook.ls_mapper[ls]]]
else:
raise ValueError()
... |
'alias for set_linestyle'
| def set_linestyles(self, ls):
| return self.set_linestyle(ls)
|
'alias for set_linestyle'
| def set_dashes(self, ls):
| return self.set_linestyle(ls)
|
'Set the antialiasing state for rendering.
ACCEPTS: Boolean or sequence of booleans'
| def set_antialiased(self, aa):
| if (aa is None):
aa = mpl.rcParams['patch.antialiased']
self._antialiaseds = self._get_bool(aa)
|
'alias for set_antialiased'
| def set_antialiaseds(self, aa):
| return self.set_antialiased(aa)
|
'Set both the edgecolor and the facecolor.
ACCEPTS: matplotlib color arg or sequence of rgba tuples
.. seealso::
:meth:`set_facecolor`, :meth:`set_edgecolor`'
| def set_color(self, c):
| self.set_facecolor(c)
self.set_edgecolor(c)
|
'Set the facecolor(s) of the collection. *c* can be a
matplotlib color arg (all patches have same color), or a
sequence or rgba tuples; if it is a sequence the patches will
cycle through the sequence
ACCEPTS: matplotlib color arg or sequence of rgba tuples'
| def set_facecolor(self, c):
| if (c is None):
c = mpl.rcParams['patch.facecolor']
self._facecolors_original = c
self._facecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
|
'alias for set_facecolor'
| def set_facecolors(self, c):
| return self.set_facecolor(c)
|
'Set the edgecolor(s) of the collection. *c* can be a
matplotlib color arg (all patches have same color), or a
sequence or rgba tuples; if it is a sequence the patches will
cycle through the sequence.
If *c* is \'face\', the edge color will always be the same as
the face color.
ACCEPTS: matplotlib color arg or sequence... | def set_edgecolor(self, c):
| if (c == 'face'):
self._edgecolors = 'face'
self._edgecolors_original = 'face'
else:
if (c is None):
c = mpl.rcParams['patch.edgecolor']
self._edgecolors_original = c
self._edgecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
|
'alias for set_edgecolor'
| def set_edgecolors(self, c):
| return self.set_edgecolor(c)
|
'Set the alpha tranparencies of the collection. *alpha* must be
a float.
ACCEPTS: float'
| def set_alpha(self, alpha):
| try:
float(alpha)
except TypeError:
raise TypeError('alpha must be a float')
else:
artist.Artist.set_alpha(self, alpha)
try:
self._facecolors = _colors.colorConverter.to_rgba_array(self._facecolors_original, self._alpha)
except (AttributeError,... |
'If the scalar mappable array is not none, update colors
from scalar data'
| def update_scalarmappable(self):
| if (self._A is None):
return
if (self._A.ndim > 1):
raise ValueError('Collections can only map rank 1 arrays')
if len(self._facecolors):
self._facecolors = self.to_rgba(self._A, self._alpha)
else:
self._edgecolors = self.to_rgba(self._A, self._alpha)
|
'copy properties from other to self'
| def update_from(self, other):
| artist.Artist.update_from(self, other)
self._antialiaseds = other._antialiaseds
self._edgecolors_original = other._edgecolors_original
self._edgecolors = other._edgecolors
self._facecolors_original = other._facecolors_original
self._facecolors = other._facecolors
self._linewidths = other._li... |
'Converts a given mesh into a sequence of
:class:`matplotlib.path.Path` objects for easier rendering by
backends that do not directly support quadmeshes.
This function is primarily of use to backend implementers.'
| def convert_mesh_to_paths(meshWidth, meshHeight, coordinates):
| Path = mpath.Path
if ma.isMaskedArray(coordinates):
c = coordinates.data
else:
c = coordinates
points = np.concatenate((c[0:(-1), 0:(-1)], c[0:(-1), 1:], c[1:, 1:], c[1:, 0:(-1)], c[0:(-1), 0:(-1)]), axis=2)
points = points.reshape(((meshWidth * meshHeight), 5, 2))
return [Path(x... |
'*verts* is a sequence of ( *verts0*, *verts1*, ...) where
*verts_i* is a sequence of *xy* tuples of vertices, or an
equivalent :mod:`numpy` array of shape (*nv*, 2).
*sizes* is *None* (default) or a sequence of floats that
scale the corresponding *verts_i*. The scaling is applied
before the Artist master transform; i... | def __init__(self, verts, sizes=None, closed=True, **kwargs):
| Collection.__init__(self, **kwargs)
self._sizes = sizes
self.set_verts(verts, closed)
|
'This allows one to delay initialization of the vertices.'
| def set_verts(self, verts, closed=True):
| if closed:
self._paths = []
for xy in verts:
if np.ma.isMaskedArray(xy):
if (len(xy) and (xy[0] != xy[(-1)]).any()):
xy = np.ma.concatenate([xy, [xy[0]]])
else:
xy = np.asarray(xy)
if (len(xy) and (xy[0] != x... |
'*xranges*
sequence of (*xmin*, *xwidth*)
*yrange*
*ymin*, *ywidth*
%(Collection)s'
| def __init__(self, xranges, yrange, **kwargs):
| (ymin, ywidth) = yrange
ymax = (ymin + ywidth)
verts = [[(xmin, ymin), (xmin, ymax), ((xmin + xwidth), ymax), ((xmin + xwidth), ymin), (xmin, ymin)] for (xmin, xwidth) in xranges]
PolyCollection.__init__(self, verts, **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'
| @staticmethod
def span_where(x, ymin, ymax, where, **kwargs):
| 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
|
'*numsides*
the number of sides of the polygon
*rotation*
the rotation of the polygon in radians
*sizes*
gives the area of the circle circumscribing the
regular polygon in points^2
%(Collection)s
Example: see :file:`examples/dynamic_collection.py` for
complete example::
offsets = np.random.rand(20,2)
facecolors = [cm.j... | def __init__(self, numsides, rotation=0, sizes=(1,), **kwargs):
| Collection.__init__(self, **kwargs)
self._sizes = sizes
self._numsides = numsides
self._paths = [self._path_generator(numsides)]
self._rotation = rotation
self.set_transform(transforms.IdentityTransform())
|
'*segments*
a sequence of (*line0*, *line1*, *line2*), where::
linen = (x0, y0), (x1, y1), ... (xm, ym)
or the equivalent numpy array with two columns. Each line
can be a different length.
*colors*
must be a sequence of RGBA tuples (eg arbitrary color
strings, etc, not allowed).
*antialiaseds*
must be a sequence of one... | def __init__(self, segments, linewidths=None, colors=None, antialiaseds=None, linestyles='solid', offsets=None, transOffset=None, norm=None, cmap=None, pickradius=5, **kwargs):
| if (colors is None):
colors = mpl.rcParams['lines.color']
if (linewidths is None):
linewidths = (mpl.rcParams['lines.linewidth'],)
if (antialiaseds is None):
antialiaseds = (mpl.rcParams['lines.antialiased'],)
self.set_linestyles(linestyles)
colors = _colors.colorConverter.to... |
'Set the color(s) of the line collection. *c* can be a
matplotlib color arg (all patches have same color), or a
sequence or rgba tuples; if it is a sequence the patches will
cycle through the sequence
ACCEPTS: matplotlib color arg or sequence of rgba tuples'
| def set_color(self, c):
| self._edgecolors = _colors.colorConverter.to_rgba_array(c)
|
'Set the color(s) of the line collection. *c* can be a
matplotlib color arg (all patches have same color), or a
sequence or rgba tuples; if it is a sequence the patches will
cycle through the sequence
ACCEPTS: matplotlib color arg or sequence of rgba tuples'
| def color(self, c):
| warnings.warn('LineCollection.color deprecated; use set_color instead')
return self.set_color(c)
|
'*sizes*
Gives the area of the circle in points^2
%(Collection)s'
| def __init__(self, sizes, **kwargs):
| Collection.__init__(self, **kwargs)
self._sizes = sizes
self.set_transform(transforms.IdentityTransform())
self._paths = [mpath.Path.unit_circle()]
|
'*widths*: sequence
half-lengths of first axes (e.g., semi-major axis lengths)
*heights*: sequence
half-lengths of second axes
*angles*: sequence
angles of first axes, degrees CCW from the X-axis
*units*: [\'points\' | \'inches\' | \'dots\' | \'width\' | \'height\' | \'x\' | \'y\']
units in which majors and minors are ... | def __init__(self, widths, heights, angles, units='points', **kwargs):
| Collection.__init__(self, **kwargs)
self._widths = np.asarray(widths).ravel()
self._heights = np.asarray(heights).ravel()
self._angles = (np.asarray(angles).ravel() * (np.pi / 180.0))
self._units = units
self.set_transform(transforms.IdentityTransform())
self._transforms = []
self._paths... |
'*patches*
a sequence of Patch objects. This list may include
a heterogeneous assortment of different patch types.
*match_original*
If True, use the colors and linewidths of the original
patches. If False, new colors may be assigned by
providing the standard collection arguments, facecolor,
edgecolor, linewidths, nor... | def __init__(self, patches, match_original=False, **kwargs):
| if match_original:
def determine_facecolor(patch):
if patch.fill:
return patch.get_facecolor()
return [0, 0, 0, 0]
facecolors = [determine_facecolor(p) for p in patches]
edgecolors = [p.get_edgecolor() for p in patches]
linewidths = [p.get_line... |
'Parse the AFM file in file object *fh*'
| def __init__(self, fh):
| (dhead, dcmetrics_ascii, dcmetrics_name, dkernpairs, dcomposite) = parse_afm(fh)
self._header = dhead
self._kern = dkernpairs
self._metrics = dcmetrics_ascii
self._metrics_by_name = dcmetrics_name
self._composite = dcomposite
|
'Return the string width (including kerning) and string height
as a (*w*, *h*) tuple.'
| def string_width_height(self, s):
| if (not len(s)):
return (0, 0)
totalw = 0
namelast = None
miny = 1000000000.0
maxy = 0
for c in s:
if (c == '\n'):
continue
(wx, name, bbox) = self._metrics[ord(c)]
(l, b, w, h) = bbox
try:
kp = self._kern[(namelast, name)]
... |
'Return the string bounding box'
| def get_str_bbox_and_descent(self, s):
| if (not len(s)):
return (0, 0, 0, 0)
totalw = 0
namelast = None
miny = 1000000000.0
maxy = 0
left = 0
if (not isinstance(s, unicode)):
s = s.decode()
for c in s:
if (c == '\n'):
continue
name = uni2type1.get(ord(c), 'question')
try:
... |
'Return the string bounding box'
| def get_str_bbox(self, s):
| return self.get_str_bbox_and_descent(s)[:4]
|
'Get the name of the character, ie, \';\' is \'semicolon\''
| def get_name_char(self, c, isord=False):
| if (not isord):
c = ord(c)
(wx, name, bbox) = self._metrics[c]
return name
|
'Get the width of the character from the character metric WX
field'
| def get_width_char(self, c, isord=False):
| if (not isord):
c = ord(c)
(wx, name, bbox) = self._metrics[c]
return wx
|
'Get the width of the character from a type1 character name'
| def get_width_from_char_name(self, name):
| (wx, bbox) = self._metrics_by_name[name]
return wx
|
'Get the height of character *c* from the bounding box. This
is the ink height (space is 0)'
| def get_height_char(self, c, isord=False):
| if (not isord):
c = ord(c)
(wx, name, bbox) = self._metrics[c]
return bbox[(-1)]
|
'Return the kerning pair distance (possibly 0) for chars *c1*
and *c2*'
| def get_kern_dist(self, c1, c2):
| (name1, name2) = (self.get_name_char(c1), self.get_name_char(c2))
return self.get_kern_dist_from_name(name1, name2)
|
'Return the kerning pair distance (possibly 0) for chars
*name1* and *name2*'
| def get_kern_dist_from_name(self, name1, name2):
| try:
return self._kern[(name1, name2)]
except:
return 0
|
'Return the font name, eg, \'Times-Roman\''
| def get_fontname(self):
| return self._header['FontName']
|
'Return the font full name, eg, \'Times-Roman\''
| def get_fullname(self):
| name = self._header.get('FullName')
if (name is None):
name = self._header['FontName']
return name
|
'Return the font family name, eg, \'Times\''
| def get_familyname(self):
| name = self._header.get('FamilyName')
if (name is not None):
return name
name = self.get_fullname()
extras = '(?i)([ -](regular|plain|italic|oblique|bold|semibold|light|ultralight|extra|condensed))+$'
return re.sub(extras, '', name)
|
'Return the font weight, eg, \'Bold\' or \'Roman\''
| def get_weight(self):
| return self._header['Weight']
|
'Return the fontangle as float'
| def get_angle(self):
| return self._header['ItalicAngle']
|
'Return the cap height as float'
| def get_capheight(self):
| return self._header['CapHeight']
|
'Return the xheight as float'
| def get_xheight(self):
| return self._header['XHeight']
|
'Return the underline thickness as float'
| def get_underline_thickness(self):
| return self._header['UnderlineThickness']
|
'Return the standard horizontal stem width as float, or *None* if
not specified in AFM file.'
| def get_horizontal_stem_width(self):
| return self._header.get('StdHW', None)
|
'Return the standard vertical stem width as float, or *None* if
not specified in AFM file.'
| def get_vertical_stem_width(self):
| return self._header.get('StdVW', None)
|
'Remove the artist from the figure if possible. The effect
will not be visible until the figure is redrawn, e.g., with
:meth:`matplotlib.axes.Axes.draw_idle`. Call
:meth:`matplotlib.axes.Axes.relim` to update the axes limits
if desired.
Note: :meth:`~matplotlib.axes.Axes.relim` will not see
collections even if the co... | def remove(self):
| if (self._remove_method != None):
self._remove_method(self)
else:
raise NotImplementedError('cannot remove artist')
|
'Return *True* if units are set on the *x* or *y* axes'
| def have_units(self):
| ax = self.axes
if ((ax is None) or (ax.xaxis is None)):
return False
return (ax.xaxis.have_units() or ax.yaxis.have_units())
|
'For artists in an axes, if the xaxis has units support,
convert *x* using xaxis unit type'
| def convert_xunits(self, x):
| ax = getattr(self, 'axes', None)
if ((ax is None) or (ax.xaxis is None)):
return x
return ax.xaxis.convert_units(x)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.