本文整理汇总了Python中cbook.Stack.push方法的典型用法代码示例。如果您正苦于以下问题:Python Stack.push方法的具体用法?Python Stack.push怎么用?Python Stack.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cbook.Stack
的用法示例。
在下文中一共展示了Stack.push方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from cbook import Stack [as 别名]
# 或者: from cbook.Stack import push [as 别名]
def add(self, key, a):
"""
Add Axes *a*, with key *key*, to the stack, and return the stack.
If *a* is already on the stack, don't add it again, but
return *None*.
"""
# All the error checking may be unnecessary; but this method
# is called so seldom that the overhead is negligible.
if not isinstance(a, Axes):
raise ValueError("second argument, %s, is not an Axes" % a)
try:
hash(key)
except TypeError:
raise ValueError("first argument, %s, is not a valid key" % key)
a_existing = self.get(key)
if a_existing is not None:
Stack.remove(self, (key, a_existing))
warnings.Warn(
"key %s already existed; Axes is being replaced" % key)
# I don't think the above should ever happen.
if a in self:
return None
self._ind += 1
return Stack.push(self, (key, (self._ind, a)))
示例2: __init__
# 需要导入模块: from cbook import Stack [as 别名]
# 或者: from cbook.Stack import push [as 别名]
#.........这里部分代码省略.........
self.mode = ''
if self._idRelease is not None:
self._idRelease = self.canvas.mpl_disconnect(self._idRelease)
self.mode = ''
if self._active:
self._idPress = self.canvas.mpl_connect(
'button_press_event', self.press_pan)
self._idRelease = self.canvas.mpl_connect(
'button_release_event', self.release_pan)
self.mode = 'pan/zoom mode'
self.set_message(self.mode)
def press(self, event):
'this will be called whenver a mouse button is pressed'
pass
def press_pan(self, event):
'the press mouse button in pan/zoom mode callback'
if event.button == 1:
self._button_pressed=1
elif event.button == 3:
self._button_pressed=3
else:
self._button_pressed=None
return
x, y = event.x, event.y
# push the current view to define home if stack is empty
if self._views.empty(): self.push_current()
for i, a in enumerate(self.canvas.figure.get_axes()):
if event.inaxes == a and event.inaxes.get_navigate():
xmin, xmax = a.get_xlim()
ymin, ymax = a.get_ylim()
lim = xmin, xmax, ymin, ymax
self._xypress = x, y, a, i, lim,a.transData.deepcopy()
self.canvas.mpl_disconnect(self._idDrag)
self._idDrag=self.canvas.mpl_connect('motion_notify_event', self.drag_pan)
break
self.press(event)
def press_zoom(self, event):
'the press mouse button in zoom to rect mode callback'
if event.button == 1:
self._button_pressed=1
elif event.button == 3:
self._button_pressed=3
else:
self._button_pressed=None
return
x, y = event.x, event.y
# push the current view to define home if stack is empty
if self._views.empty(): self.push_current()
for i, a in enumerate(self.canvas.figure.get_axes()):
if event.inaxes==a and event.inaxes.get_navigate():
xmin, xmax = a.get_xlim()
示例3: Figure
# 需要导入模块: from cbook import Stack [as 别名]
# 或者: from cbook.Stack import push [as 别名]
#.........这里部分代码省略.........
creation of a new axes, you must use a unique set of args and
kwargs. The axes :attr:`~matplotlib.axes.Axes.label`
attribute has been exposed for this purpose. Eg., if you want
two axes that are otherwise identical to be added to the
figure, make sure you give them unique labels::
fig.add_axes(rect, label='axes1')
fig.add_axes(rect, label='axes2')
The :class:`~matplotlib.axes.Axes` instance will be returned.
The following kwargs are supported:
%(Axes)s
"""
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 = kwargs.pop('polar', False)
projection = kwargs.pop('projection', None)
if ispolar:
if projection is not None and projection != 'polar':
raise ValueError(
"polar=True, yet projection='%s'. " +
"Only one of these arguments should be supplied." %
projection)
projection = 'polar'
a = projection_factory(projection, self, rect, **kwargs)
self.axes.append(a)
self._axstack.push(a)
self.sca(a)
self._seen[key] = a
return a
add_axes.__doc__ = dedent(add_axes.__doc__) % \
{'list': (", ".join(get_projection_names())),
'Axes': artist.kwdocd['Axes']}
def add_subplot(self, *args, **kwargs):
"""
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 :class:`!matplotlib.axes.Axes` kwargs plus
*projection*, which chooses a projection type for the axes.
(For backward compatibility, *polar=True* may also be
provided, which is equivalent to *projection='polar'*). Valid
values for *projection* are: %(list)s. Some of these projections
support additional *kwargs*, which may be provided to
:meth:`add_axes`.
The :class:`~matplotlib.axes.Axes` instance will be returned.
If the figure already has a subplot with key (*args*,
*kwargs*) then it will simply make that subplot current and
return it.
The following kwargs are supported:
%(Axes)s
"""
kwargs = kwargs.copy()
if not len(args): return
if isinstance(args[0], SubplotBase):
示例4: Figure
# 需要导入模块: from cbook import Stack [as 别名]
# 或者: from cbook.Stack import push [as 别名]
#.........这里部分代码省略.........
unique labels:
add_axes(rect, label='axes1')
add_axes(rect, label='axes2')
The Axes instance will be returned
The following kwargs are supported:
%(Axes)s
"""
key = self._make_key(*args, **kwargs)
if self._seen.has_key(key):
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 = kwargs.pop('polar', False)
if ispolar:
a = PolarAxes(self, rect, **kwargs)
else:
a = Axes(self, rect, **kwargs)
self.axes.append(a)
self._axstack.push(a)
self.sca(a)
self._seen[key] = a
return a
add_axes.__doc__ = dedent(add_axes.__doc__) % artist.kwdocd
def add_subplot(self, *args, **kwargs):
"""
Add a subplot. Examples
add_subplot(111)
add_subplot(212, axisbg='r') # add subplot with red background
add_subplot(111, polar=True) # add a polar subplot
add_subplot(sub) # add Subplot instance sub
kwargs are legal Axes kwargs plus"polar" which sets whether to create a
polar axes. The Axes instance will be returned.
If the figure already has a subplot with key *args, *kwargs then it will
simply make that subplot current and return it
The following kwargs are supported:
%(Axes)s
"""
key = self._make_key(*args, **kwargs)
if self._seen.has_key(key):
ax = self._seen[key]
self.sca(ax)
return ax