desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'on button press event'
| def press(self, event):
| if self.ignore(event):
return
self.to_draw.set_visible(self.visible)
self.eventpress = event
return False
|
'on button release event'
| def release(self, event):
| if ((self.eventpress is None) or self.ignore(event)):
return
self.to_draw.set_visible(False)
self.canvas.draw()
self.eventrelease = event
if (self.spancoords == 'data'):
(xmin, ymin) = (self.eventpress.xdata, self.eventpress.ydata)
(xmax, ymax) = (self.eventrelease.xdata, self.eventrelease.ydata)
elif (self.spancoords == 'pixels'):
(xmin, ymin) = (self.eventpress.x, self.eventpress.y)
(xmax, ymax) = (self.eventrelease.x, self.eventrelease.y)
else:
raise ValueError('spancoords must be "data" or "pixels"')
if (xmin > xmax):
(xmin, xmax) = (xmax, xmin)
if (ymin > ymax):
(ymin, ymax) = (ymax, ymin)
spanx = (xmax - xmin)
spany = (ymax - ymin)
xproblems = ((self.minspanx is not None) and (spanx < self.minspanx))
yproblems = ((self.minspany is not None) and (spany < self.minspany))
if ((self.drawtype == 'box') and (xproblems or yproblems)):
'Box to small'
return
if ((self.drawtype == 'line') and (xproblems and yproblems)):
'Line to small'
return
self.onselect(self.eventpress, self.eventrelease)
self.eventpress = None
self.eventrelease = None
return False
|
'draw using newfangled blit or oldfangled draw depending on useblit'
| def update(self):
| if self.useblit:
if (self.background is not None):
self.canvas.restore_region(self.background)
self.ax.draw_artist(self.to_draw)
self.canvas.blit(self.ax.bbox)
else:
self.canvas.draw_idle()
return False
|
'on motion notify event if box/line is wanted'
| def onmove(self, event):
| if ((self.eventpress is None) or self.ignore(event)):
return
(x, y) = (event.xdata, event.ydata)
if (self.drawtype == 'box'):
(minx, maxx) = (self.eventpress.xdata, x)
(miny, maxy) = (self.eventpress.ydata, y)
if (minx > maxx):
(minx, maxx) = (maxx, minx)
if (miny > maxy):
(miny, maxy) = (maxy, miny)
self.to_draw.set_x(minx)
self.to_draw.set_y(miny)
self.to_draw.set_width((maxx - minx))
self.to_draw.set_height((maxy - miny))
self.update()
return False
if (self.drawtype == 'line'):
self.to_draw.set_data([self.eventpress.xdata, x], [self.eventpress.ydata, y])
self.update()
return False
|
'Use this to activate / deactivate the RectangleSelector
from your program with an boolean variable \'active\'.'
| def set_active(self, active):
| self.active = active
|
'to get status of active mode (boolean variable)'
| def get_active(self):
| return self.active
|
'majloc and minloc: TickLocators for the major and minor ticks
majfmt and minfmt: TickFormatters for the major and minor ticks
label: the default axis label
If any of the above are None, the axis will simply use the default'
| def __init__(self, majloc=None, minloc=None, majfmt=None, minfmt=None, label=None):
| self.majloc = majloc
self.minloc = minloc
self.majfmt = majfmt
self.minfmt = minfmt
self.label = label
|
'return an units.AxisInfo instance for unit'
| def axisinfo(unit):
| return None
|
'return the default unit for x or None'
| def default_units(x):
| return None
|
'convert obj using unit. If obj is a sequence, return the
converted sequence. The ouput must be a sequence of scalars
that can be used by the numpy array layer'
| def convert(obj, unit):
| return obj
|
'The matplotlib datalim, autoscaling, locators etc work with
scalars which are the units converted to floats given the
current unit. The converter may be passed these floats, or
arrays of them, even when units are set. Derived conversion
interfaces may opt to pass plain-ol unitless numbers through
the conversion interface and this is a helper function for
them.'
| def is_numlike(x):
| if iterable(x):
for thisx in x:
return is_numlike(thisx)
else:
return is_numlike(x)
|
'get the converter interface instance for x, or None'
| def get_converter(self, x):
| if (not len(self)):
return None
converter = None
classx = getattr(x, '__class__', None)
if (classx is not None):
converter = self.get(classx)
if ((converter is None) and iterable(x)):
if (isinstance(x, np.ndarray) and (x.dtype != np.object)):
return None
for thisx in x:
converter = self.get_converter(thisx)
return converter
return converter
|
'fmt: any valid strptime format is supported'
| def __init__(self, fmt):
| self.fmt = fmt
|
's : string to be converted
return value: a date2num float'
| def __call__(self, s):
| return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))
|
'*fmt* is an :func:`strftime` format string; *tz* is the
:class:`tzinfo` instance.'
| def __init__(self, fmt, tz=None):
| if (tz is None):
tz = _get_rc_timezone()
self.fmt = fmt
self.tz = tz
|
'*t* is a sequence of dates (floating point days). *fmt* is a
:func:`strftime` format string.'
| def __init__(self, t, fmt, tz=None):
| if (tz is None):
tz = _get_rc_timezone()
self.t = t
self.fmt = fmt
self.tz = tz
|
'Return the label for time *x* at position *pos*'
| def __call__(self, x, pos=0):
| ind = int(round(x))
if ((ind >= len(self.t)) or (ind <= 0)):
return ''
dt = num2date(self.t[ind], self.tz)
return cbook.unicode_safe(dt.strftime(self.fmt))
|
'*tz* is a :class:`tzinfo` instance.'
| def __init__(self, tz=None):
| if (tz is None):
tz = _get_rc_timezone()
self.tz = tz
|
'Return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| return 1
|
'Return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| freq = self.rule._rrule._freq
if (freq == YEARLY):
return 365
elif (freq == MONTHLY):
return 30
elif (freq == WEEKLY):
return 7
elif (freq == DAILY):
return 1
elif (freq == HOURLY):
return (1.0 / 24.0)
elif (freq == MINUTELY):
return (1.0 / (24 * 60))
elif (freq == SECONDLY):
return (1.0 / (24 * 3600))
else:
return (-1)
|
'Set the view limits to include the data range.'
| def autoscale(self):
| (dmin, dmax) = self.datalim_to_dt()
if (dmin > dmax):
(dmax, dmin) = (dmin, dmax)
delta = relativedelta(dmax, dmin)
self.rule.set(dtstart=(dmin - delta), until=(dmax + delta))
(dmin, dmax) = self.datalim_to_dt()
vmin = self.rule.before(dmin, True)
if (not vmin):
vmin = dmin
vmax = self.rule.after(dmax, True)
if (not vmax):
vmax = dmax
vmin = date2num(vmin)
vmax = date2num(vmax)
return self.nonsingular(vmin, vmax)
|
'Return the locations of the ticks'
| def __call__(self):
| self.refresh()
return self._locator()
|
'Refresh internal information based on current limits.'
| def refresh(self):
| (dmin, dmax) = self.viewlim_to_dt()
self._locator = self.get_locator(dmin, dmax)
|
'Try to choose the view limits intelligently.'
| def autoscale(self):
| (dmin, dmax) = self.datalim_to_dt()
self._locator = self.get_locator(dmin, dmax)
return self._locator.autoscale()
|
'Pick the best locator based on a distance.'
| def get_locator(self, dmin, dmax):
| delta = relativedelta(dmax, dmin)
numYears = (delta.years * 1.0)
numMonths = ((numYears * 12.0) + delta.months)
numDays = ((numMonths * 31.0) + delta.days)
numHours = ((numDays * 24.0) + delta.hours)
numMinutes = ((numHours * 60.0) + delta.minutes)
numSeconds = ((numMinutes * 60.0) + delta.seconds)
numticks = 5
interval = 1
bymonth = 1
bymonthday = 1
byhour = 0
byminute = 0
bysecond = 0
if (numYears >= numticks):
self._freq = YEARLY
elif (numMonths >= numticks):
self._freq = MONTHLY
bymonth = range(1, 13)
if ((0 <= numMonths) and (numMonths <= 14)):
interval = 1
elif ((15 <= numMonths) and (numMonths <= 29)):
interval = 3
elif ((30 <= numMonths) and (numMonths <= 44)):
interval = 4
else:
interval = 6
elif (numDays >= numticks):
self._freq = DAILY
bymonth = None
bymonthday = range(1, 32)
if ((0 <= numDays) and (numDays <= 9)):
interval = 1
elif ((10 <= numDays) and (numDays <= 19)):
interval = 2
elif ((20 <= numDays) and (numDays <= 49)):
interval = 3
elif ((50 <= numDays) and (numDays <= 99)):
interval = 7
else:
interval = 14
elif (numHours >= numticks):
self._freq = HOURLY
bymonth = None
bymonthday = None
byhour = range(0, 24)
if ((0 <= numHours) and (numHours <= 14)):
interval = 1
elif ((15 <= numHours) and (numHours <= 30)):
interval = 2
elif ((30 <= numHours) and (numHours <= 45)):
interval = 3
elif ((45 <= numHours) and (numHours <= 68)):
interval = 4
elif ((68 <= numHours) and (numHours <= 90)):
interval = 6
else:
interval = 12
elif (numMinutes >= numticks):
self._freq = MINUTELY
bymonth = None
bymonthday = None
byhour = None
byminute = range(0, 60)
if (numMinutes > (10.0 * numticks)):
interval = 10
elif (numSeconds >= numticks):
self._freq = SECONDLY
bymonth = None
bymonthday = None
byhour = None
byminute = None
bysecond = range(0, 60)
if (numSeconds > (10.0 * numticks)):
interval = 10
else:
pass
rrule = rrulewrapper(self._freq, interval=interval, dtstart=dmin, until=dmax, bymonth=bymonth, bymonthday=bymonthday, byhour=byhour, byminute=byminute, bysecond=bysecond)
locator = RRuleLocator(rrule, self.tz)
locator.set_axis(self.axis)
locator.set_view_interval(*self.axis.get_view_interval())
locator.set_data_interval(*self.axis.get_data_interval())
return locator
|
'Mark years that are multiple of base on a given month and day
(default jan 1).'
| def __init__(self, base=1, month=1, day=1, tz=None):
| DateLocator.__init__(self, tz)
self.base = ticker.Base(base)
self.replaced = {'month': month, 'day': day, 'hour': 0, 'minute': 0, 'second': 0, 'tzinfo': tz}
|
'Return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| return 365
|
'Set the view limits to include the data range.'
| def autoscale(self):
| (dmin, dmax) = self.datalim_to_dt()
ymin = self.base.le(dmin.year)
ymax = self.base.ge(dmax.year)
vmin = dmin.replace(year=ymin, **self.replaced)
vmax = dmax.replace(year=ymax, **self.replaced)
vmin = date2num(vmin)
vmax = date2num(vmax)
return self.nonsingular(vmin, vmax)
|
'Mark every month in *bymonth*; *bymonth* can be an int or
sequence. Default is ``range(1,13)``, i.e. every month.
*interval* is the interval between each iteration. For
example, if ``interval=2``, mark every second occurance.'
| def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None):
| if (bymonth is None):
bymonth = range(1, 13)
o = rrulewrapper(MONTHLY, bymonth=bymonth, bymonthday=bymonthday, interval=interval, **self.hms0d)
RRuleLocator.__init__(self, o, tz)
|
'Return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| return 30
|
'Mark every weekday in *byweekday*; *byweekday* can be a number or
sequence.
Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA,
SU, the constants from :mod:`dateutils.rrule`.
*interval* specifies the number of weeks to skip. For example,
``interval=2`` plots every second week.'
| def __init__(self, byweekday=1, interval=1, tz=None):
| o = rrulewrapper(DAILY, byweekday=byweekday, interval=interval, **self.hms0d)
RRuleLocator.__init__(self, o, tz)
|
'return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| return 7
|
'Mark every day in *bymonthday*; *bymonthday* can be an int or
sequence.
Default is to tick every day of the month: ``bymonthday=range(1,32)``'
| def __init__(self, bymonthday=None, interval=1, tz=None):
| if (bymonthday is None):
bymonthday = range(1, 32)
o = rrulewrapper(DAILY, bymonthday=bymonthday, interval=interval, **self.hms0d)
RRuleLocator.__init__(self, o, tz)
|
'Return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| return 1
|
'Mark every hour in *byhour*; *byhour* can be an int or sequence.
Default is to tick every hour: ``byhour=range(24)``
*interval* is the interval between each iteration. For
example, if ``interval=2``, mark every second occurrence.'
| def __init__(self, byhour=None, interval=1, tz=None):
| if (byhour is None):
byhour = range(24)
rule = rrulewrapper(HOURLY, byhour=byhour, interval=interval, byminute=0, bysecond=0)
RRuleLocator.__init__(self, rule, tz)
|
'return how many days a unit of the locator is; use for
intelligent autoscaling'
| def _get_unit(self):
| return (1 / 24.0)
|
'Mark every minute in *byminute*; *byminute* can be an int or
sequence. Default is to tick every minute: ``byminute=range(60)``
*interval* is the interval between each iteration. For
example, if ``interval=2``, mark every second occurrence.'
| def __init__(self, byminute=None, interval=1, tz=None):
| if (byminute is None):
byminute = range(60)
rule = rrulewrapper(MINUTELY, byminute=byminute, interval=interval, bysecond=0)
RRuleLocator.__init__(self, rule, tz)
|
'Return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| return (1.0 / (24 * 60))
|
'Mark every second in *bysecond*; *bysecond* can be an int or
sequence. Default is to tick every second: ``bysecond = range(60)``
*interval* is the interval between each iteration. For
example, if ``interval=2``, mark every second occurrence.'
| def __init__(self, bysecond=None, interval=1, tz=None):
| if (bysecond is None):
bysecond = range(60)
rule = rrulewrapper(SECONDLY, bysecond=bysecond, interval=interval)
RRuleLocator.__init__(self, rule, tz)
|
'Return how many days a unit of the locator is; used for
intelligent autoscaling.'
| def _get_unit(self):
| return (1.0 / ((24 * 60) * 60))
|
'return the unit AxisInfo'
| def axisinfo(unit):
| if (unit == 'date'):
majloc = AutoDateLocator()
majfmt = AutoDateFormatter(majloc)
return units.AxisInfo(majloc=majloc, majfmt=majfmt, label='')
else:
return None
|
'Return the default unit for *x* or None'
| def default_units(x):
| return 'date'
|
'Set the figure
accepts a class:`~matplotlib.figure.Figure` instance'
| def set_figure(self, fig):
| martist.Artist.set_figure(self, fig)
for c in self.get_children():
c.set_figure(fig)
|
'Set the offset
accepts x, y, tuple, or a callable object.'
| def set_offset(self, xy):
| self._offset = xy
|
'Get the offset
accepts extent of the box'
| def get_offset(self, width, height, xdescent, ydescent):
| if callable(self._offset):
return self._offset(width, height, xdescent, ydescent)
else:
return self._offset
|
'Set the width
accepts float'
| def set_width(self, width):
| self.width = width
|
'Set the height
accepts float'
| def set_height(self, height):
| self.height = height
|
'Return a list of artists it contains.'
| def get_children(self):
| return self._children
|
'Return with, height, xdescent, ydescent of box'
| def get_extent(self, renderer):
| (w, h, xd, yd, offsets) = self.get_extent_offsets(renderer)
return (w, h, xd, yd)
|
'get the bounding box in display space.'
| def get_window_extent(self, renderer):
| (w, h, xd, yd, offsets) = self.get_extent_offsets(renderer)
(px, py) = self.get_offset(w, h, xd, yd)
return mtransforms.Bbox.from_bounds((px - xd), (py - yd), w, h)
|
'Update the location of children if necessary and draw them
to the given *renderer*.'
| def draw(self, renderer):
| (width, height, xdescent, ydescent, offsets) = self.get_extent_offsets(renderer)
(px, py) = self.get_offset(width, height, xdescent, ydescent)
for (c, (ox, oy)) in zip(self.get_children(), offsets):
c.set_offset(((px + ox), (py + oy)))
c.draw(renderer)
bbox_artist(self, renderer, fill=False, props=dict(pad=0.0))
|
'*pad* : boundary pad
*sep* : spacing between items
*width*, *height* : width and height of the container box.
calculated if None.
*align* : alignment of boxes
*mode* : packing mode'
| def __init__(self, pad=None, sep=None, width=None, height=None, align=None, mode=None, children=None):
| super(PackerBase, self).__init__()
self.height = height
self.width = width
self.sep = sep
self.pad = pad
self.mode = mode
self.align = align
self._children = children
|
'*pad* : boundary pad
*sep* : spacing between items
*width*, *height* : width and height of the container box.
calculated if None.
*align* : alignment of boxes
*mode* : packing mode'
| def __init__(self, pad=None, sep=None, width=None, height=None, align='baseline', mode='fixed', children=None):
| super(VPacker, self).__init__(pad, sep, width, height, align, mode, children)
|
'update offset of childrens and return the extents of the box'
| def get_extent_offsets(self, renderer):
| whd_list = [c.get_extent(renderer) for c in self.get_children()]
whd_list = [(w, h, xd, (h - yd)) for (w, h, xd, yd) in whd_list]
wd_list = [(w, xd) for (w, h, xd, yd) in whd_list]
(width, xdescent, xoffsets) = _get_aligned_offsets(wd_list, self.width, self.align)
pack_list = [(h, yd) for (w, h, xd, yd) in whd_list]
(height, yoffsets_) = _get_packed_offsets(pack_list, self.height, self.sep, self.mode)
yoffsets = (yoffsets_ + [yd for (w, h, xd, yd) in whd_list])
ydescent = (height - yoffsets[0])
yoffsets = (height - yoffsets)
yoffsets = (yoffsets - ydescent)
return ((width + (2 * self.pad)), (height + (2 * self.pad)), (xdescent + self.pad), (ydescent + self.pad), zip(xoffsets, yoffsets))
|
'*pad* : boundary pad
*sep* : spacing between items
*width*, *height* : width and height of the container box.
calculated if None.
*align* : alignment of boxes
*mode* : packing mode'
| def __init__(self, pad=None, sep=None, width=None, height=None, align='baseline', mode='fixed', children=None):
| super(HPacker, self).__init__(pad, sep, width, height, align, mode, children)
|
'update offset of childrens and return the extents of the box'
| def get_extent_offsets(self, renderer):
| whd_list = [c.get_extent(renderer) for c in self.get_children()]
if (self.height is None):
height_descent = max([(h - yd) for (w, h, xd, yd) in whd_list])
ydescent = max([yd for (w, h, xd, yd) in whd_list])
height = (height_descent + ydescent)
else:
height = (self.height - (2 * self._pad))
hd_list = [(h, yd) for (w, h, xd, yd) in whd_list]
(height, ydescent, yoffsets) = _get_aligned_offsets(hd_list, self.height, self.align)
pack_list = [(w, xd) for (w, h, xd, yd) in whd_list]
(width, xoffsets_) = _get_packed_offsets(pack_list, self.width, self.sep, self.mode)
xoffsets = (xoffsets_ + [xd for (w, h, xd, yd) in whd_list])
xdescent = whd_list[0][2]
xoffsets = (xoffsets - xdescent)
return ((width + (2 * self.pad)), (height + (2 * self.pad)), (xdescent + self.pad), (ydescent + self.pad), zip(xoffsets, yoffsets))
|
'*width*, *height* : width and height of the container box.
*xdescent*, *ydescent* : descent of the box in x- and y-direction.'
| def __init__(self, width, height, xdescent=0.0, ydescent=0.0, clip=True):
| super(DrawingArea, self).__init__()
self.width = width
self.height = height
self.xdescent = xdescent
self.ydescent = ydescent
self.offset_transform = mtransforms.Affine2D()
self.offset_transform.clear()
self.offset_transform.translate(0, 0)
|
'Return the :class:`~matplotlib.transforms.Transform` applied
to the children'
| def get_transform(self):
| return self.offset_transform
|
'set_transform is ignored.'
| def set_transform(self, t):
| pass
|
'set offset of the container.
Accept : tuple of x,y cooridnate in disokay units.'
| def set_offset(self, xy):
| self._offset = xy
self.offset_transform.clear()
self.offset_transform.translate(xy[0], xy[1])
|
'return offset of the container.'
| def get_offset(self):
| return self._offset
|
'get the bounding box in display space.'
| def get_window_extent(self, renderer):
| (w, h, xd, yd) = self.get_extent(renderer)
(ox, oy) = self.get_offset()
return mtransforms.Bbox.from_bounds((ox - xd), (oy - yd), w, h)
|
'Return with, height, xdescent, ydescent of box'
| def get_extent(self, renderer):
| return (self.width, self.height, self.xdescent, self.ydescent)
|
'Add any :class:`~matplotlib.artist.Artist` to the container box'
| def add_artist(self, a):
| self._children.append(a)
a.set_transform(self.get_transform())
|
'Draw the children'
| def draw(self, renderer):
| for c in self._children:
c.draw(renderer)
bbox_artist(self, renderer, fill=False, props=dict(pad=0.0))
|
'*s* : a string to be displayed.
*textprops* : property dictionary for the text
*multilinebaseline* : If True, baseline for multiline text is
adjusted so that it is (approximatedly)
center-aligned with singleline text.
*minimumdescent* : If True, the box has a minimum descent of "p".'
| def __init__(self, s, textprops=None, multilinebaseline=None, minimumdescent=True):
| if (textprops is None):
textprops = {}
if (not textprops.has_key('va')):
textprops['va'] = 'baseline'
self._text = mtext.Text(0, 0, s, **textprops)
OffsetBox.__init__(self)
self._children = [self._text]
self.offset_transform = mtransforms.Affine2D()
self.offset_transform.clear()
self.offset_transform.translate(0, 0)
self._baseline_transform = mtransforms.Affine2D()
self._text.set_transform((self.offset_transform + self._baseline_transform))
self._multilinebaseline = multilinebaseline
self._minimumdescent = minimumdescent
|
'Set multilinebaseline .
If True, baseline for multiline text is
adjusted so that it is (approximatedly) center-aligned with
singleline text.'
| def set_multilinebaseline(self, t):
| self._multilinebaseline = t
|
'get multilinebaseline .'
| def get_multilinebaseline(self):
| return self._multilinebaseline
|
'Set minimumdescent .
If True, extent of the single line text is adjusted so that
it has minimum descent of "p"'
| def set_minimumdescent(self, t):
| self._minimumdescent = t
|
'get minimumdescent.'
| def get_minimumdescent(self):
| return self._minimumdescent
|
'set_transform is ignored.'
| def set_transform(self, t):
| pass
|
'set offset of the container.
Accept : tuple of x,y cooridnate in disokay units.'
| def set_offset(self, xy):
| self._offset = xy
self.offset_transform.clear()
self.offset_transform.translate(xy[0], xy[1])
|
'return offset of the container.'
| def get_offset(self):
| return self._offset
|
'get the bounding box in display space.'
| def get_window_extent(self, renderer):
| (w, h, xd, yd) = self.get_extent(renderer)
(ox, oy) = self.get_offset()
return mtransforms.Bbox.from_bounds((ox - xd), (oy - yd), w, h)
|
'Draw the children'
| def draw(self, renderer):
| self._text.draw(renderer)
bbox_artist(self, renderer, fill=False, props=dict(pad=0.0))
|
'Return the format for tick val x at position pos; pos=None indicated unspecified'
| def __call__(self, x, pos=None):
| raise NotImplementedError('Derived must overide')
|
'return a short string version'
| def format_data_short(self, value):
| return self.format_data(value)
|
'some classes may want to replace a hyphen for minus with the
proper unicode symbol as described `here
<http://sourceforge.net/tracker/index.php?func=detail&aid=1962574&group_id=80706&atid=560720>`_.
The default is to do nothing
Note, if you use this method, eg in :meth`format_data` or
call, you probably don\'t want to use it for
:meth:`format_data_short` since the toolbar uses this for
interative coord reporting and I doubt we can expect GUIs
across platforms will handle the unicode correctly. So for
now the classes that override :meth:`fix_minus` should have an
explicit :meth:`format_data_short` method'
| def fix_minus(self, s):
| return s
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| return ''
|
'seq is a sequence of strings. For positions `i<len(seq)` return
*seq[i]* regardless of *x*. Otherwise return \'\''
| def __init__(self, seq):
| self.seq = seq
self.offset_string = ''
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| if ((pos is None) or (pos >= len(self.seq))):
return ''
else:
return self.seq[pos]
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| return self.func(x, pos)
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| return (self.fmt % x)
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| (xmin, xmax) = self.axis.get_view_interval()
d = abs((xmax - xmin))
return self.pprint_val(x, d)
|
'use a unicode minus rather than hyphen'
| def fix_minus(self, s):
| if (rcParams['text.usetex'] or (not rcParams['axes.unicode_minus'])):
return s
else:
return s.replace('-', u'\u2212')
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| if (len(self.locs) == 0):
return ''
else:
s = self.pprint_val(x)
return self.fix_minus(s)
|
'True or False to turn scientific notation on or off
see also :meth:`set_powerlimits`'
| def set_scientific(self, b):
| self._scientific = bool(b)
|
'Sets size thresholds for scientific notation.
e.g. ``xaxis.set_powerlimits((-3, 4))`` sets the pre-2007 default in
which scientific notation is used for numbers less than
1e-3 or greater than 1e4.
See also :meth:`set_scientific`.'
| def set_powerlimits(self, lims):
| assert (len(lims) == 2), 'argument must be a sequence of length 2'
self._powerlimits = lims
|
'return a short formatted string representation of a number'
| def format_data_short(self, value):
| return ('%1.3g' % value)
|
'return a formatted string representation of a number'
| def format_data(self, value):
| s = self._formatSciNotation(('%1.10e' % value))
return self.fix_minus(s)
|
'Return scientific notation, plus offset'
| def get_offset(self):
| if (len(self.locs) == 0):
return ''
s = ''
if (self.orderOfMagnitude or self.offset):
offsetStr = ''
sciNotStr = ''
if self.offset:
offsetStr = self.format_data(self.offset)
if (self.offset > 0):
offsetStr = ('+' + offsetStr)
if self.orderOfMagnitude:
if (self._usetex or self._useMathText):
sciNotStr = self.format_data((10 ** self.orderOfMagnitude))
else:
sciNotStr = ('1e%d' % self.orderOfMagnitude)
if self._useMathText:
if (sciNotStr != ''):
sciNotStr = ('\\times\\mathdefault{%s}' % sciNotStr)
s = ''.join(('$', sciNotStr, '\\mathdefault{', offsetStr, '}$'))
elif self._usetex:
if (sciNotStr != ''):
sciNotStr = ('\\times%s' % sciNotStr)
s = ''.join(('$', sciNotStr, offsetStr, '$'))
else:
s = ''.join((sciNotStr, offsetStr))
return self.fix_minus(s)
|
'set the locations of the ticks'
| def set_locs(self, locs):
| self.locs = locs
if (len(self.locs) > 0):
(vmin, vmax) = self.axis.get_view_interval()
d = abs((vmax - vmin))
if self._useOffset:
self._set_offset(d)
self._set_orderOfMagnitude(d)
self._set_format()
|
'*base* is used to locate the decade tick,
which will be the only one to be labeled if *labelOnlyBase*
is ``False``'
| def __init__(self, base=10.0, labelOnlyBase=True):
| self._base = (base + 0.0)
self.labelOnlyBase = labelOnlyBase
self.decadeOnly = True
|
'change the *base* for labeling - warning: should always match the base used for :class:`LogLocator`'
| def base(self, base):
| self._base = base
|
'switch on/off minor ticks labeling'
| def label_minor(self, labelOnlyBase):
| self.labelOnlyBase = labelOnlyBase
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| (vmin, vmax) = self.axis.get_view_interval()
d = abs((vmax - vmin))
b = self._base
if (x == 0.0):
return '0'
sign = np.sign(x)
fx = (math.log(abs(x)) / math.log(b))
isDecade = self.is_decade(fx)
if ((not isDecade) and self.labelOnlyBase):
s = ''
elif (x > 10000):
s = ('%1.0e' % x)
elif (x < 1):
s = ('%1.0e' % x)
else:
s = self.pprint_val(x, d)
if (sign == (-1)):
s = ('-%s' % s)
return self.fix_minus(s)
|
'return a short formatted string representation of a number'
| def format_data_short(self, value):
| return ('%1.3g' % value)
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| (vmin, vmax) = self.axis.get_view_interval()
(vmin, vmax) = mtransforms.nonsingular(vmin, vmax, expander=0.05)
d = abs((vmax - vmin))
b = self._base
if (x == 0):
return '0'
sign = np.sign(x)
fx = (math.log(abs(x)) / math.log(b))
isDecade = self.is_decade(fx)
if ((not isDecade) and self.labelOnlyBase):
s = ''
elif (fx > 10000):
s = ('%1.0e' % fx)
elif (fx < 1):
s = ('%1.0e' % fx)
else:
s = self.pprint_val(fx, d)
if (sign == (-1)):
s = ('-%s' % s)
return self.fix_minus(s)
|
'Return the format for tick val *x* at position *pos*'
| def __call__(self, x, pos=None):
| b = self._base
if (x == 0):
return '$0$'
sign = np.sign(x)
fx = (math.log(abs(x)) / math.log(b))
isDecade = self.is_decade(fx)
usetex = rcParams['text.usetex']
if (sign == (-1)):
sign_string = '-'
else:
sign_string = ''
if ((not isDecade) and self.labelOnlyBase):
s = ''
elif (not isDecade):
if usetex:
s = ('$%s%d^{%.2f}$' % (sign_string, b, fx))
else:
s = ('$\\mathdefault{%s%d^{%.2f}}$' % (sign_string, b, fx))
elif usetex:
s = ('$%s%d^{%d}$' % (sign_string, b, self.nearest_long(fx)))
else:
s = ('$\\mathdefault{%s%d^{%d}}$' % (sign_string, b, self.nearest_long(fx)))
return s
|
'Return the locations of the ticks'
| def __call__(self):
| raise NotImplementedError('Derived must override')
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.