本文整理汇总了Python中matplotlib.widgets.AxesWidget.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python AxesWidget.__init__方法的具体用法?Python AxesWidget.__init__怎么用?Python AxesWidget.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.widgets.AxesWidget
的用法示例。
在下文中一共展示了AxesWidget.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, onselect, useblit=False, button=None,
state_modifier_keys=None):
AxesWidget.__init__(self, ax)
self.visible = True
self.onselect = onselect
self.useblit = useblit and self.canvas.supports_blit
self.connect_default_events()
self.state_modifier_keys = dict(move=' ', clear='escape',
square='shift', center='control')
self.state_modifier_keys.update(state_modifier_keys or {})
self.background = None
self.artists = []
if isinstance(button, int):
self.validButtons = [button]
else:
self.validButtons = button
# will save the data (position at mouseclick)
self.eventpress = None
# will save the data (pos. at mouserelease)
self.eventrelease = None
self._prev_event = None
self.state = set()
示例2: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, label, image=None,
color='0.85', hovercolor='0.95'):
AxesWidget.__init__(self, ax)
if image is not None:
ax.imshow(image)
self.label = ax.text(0.5, 0.5, label,
verticalalignment='center',
horizontalalignment='center',
transform=ax.transAxes)
self.cnt = 0
self.observers = {}
self.connect_event('button_press_event', self._click)
self.connect_event('button_release_event', self._release)
self.connect_event('motion_notify_event', self._motion)
ax.set_navigate(False)
ax.set_axis_bgcolor(color)
ax.set_xticks([])
ax.set_yticks([])
# self.ax.spines['top'].set_visible(False)
# self.ax.spines['right'].set_visible(False)
# self.ax.spines['bottom'].set_visible(False)
# self.ax.spines['left'].set_visible(False)
self.color = color
self.hovercolor = hovercolor
self._lastcolor = color
示例3: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, is_closed=False, max_points=None,
line_kw=None, circle_kw=None):
AxesWidget.__init__(self, ax)
self.visible = True
self.observers = {}
self.release_observers = {}
self.cid = 0
self.xs = []
self.ys = []
kw = line_kw if line_kw is not None else {}
self.line = Line2D(self.xs, self.ys, **kw)
self.ax.add_artist(self.line)
self.circle_kw = dict(radius=5, alpha=0.5)
if circle_kw:
self.circle_kw.update(circle_kw)
self.circles = []
self.is_closed = is_closed
self.max_points = max_points
self.moving_ci = None
self.connect_event('button_press_event', self._press)
self.connect_event('button_release_event', self._release)
self.connect_event('motion_notify_event', self._motion)
示例4: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax,
is_closed=False, max_points=None, grows=True, shrinks=True,
line_kw=None, circle_kw=None):
AxesWidget.__init__(self, ax)
Actionable.__init__(self)
self.visible = True
self.observers = {}
self.release_observers = {}
self.cid = 0
self.xs = []
self.ys = []
kw = line_kw if line_kw is not None else {}
self.line, = self.ax.plot(self.xs, self.ys, **kw)
self.circle_kw = circle_kw if circle_kw is not None else {}
self.circles = []
self.moving_ci = None
self.is_closed = is_closed
self.max_points = max_points
self._lclick_cids = None
self.grows = grows
self._rclick_cids = None
self._can_shrink = False
self.shrinks = shrinks
self.connect_event('button_press_event', self._left_press),
self.connect_event('button_release_event', self._release),
self.connect_event('motion_notify_event', self._motion),
示例5: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, name, data, wdlength, min_wdlength):
"""
Create a slider from *valmin* to *valmax* in axes *ax*
"""
AxesWidget.__init__(self, ax)
self.wdlength = wdlength
self.min_wdlength = min_wdlength
self.voffset = 0
self.xmax = len(data)
self.xmin = max(0, self.xmax-self.wdlength)
self.ymax = np.max(data.high[self.xmin : self.xmax].values) + self.voffset
self.ymin = np.min(data.low[self.xmin : self.xmax].values) - self.voffset
self.ax = ax
self.cnt = 0
self.observers = {}
self.data = data
self.name = name
ax.set_xlim((self.xmin, self.xmax))
ax.set_ylim((self.ymin, self.ymax))
self.a1, self.a2 = candlestick2(ax, data.open.tolist()[:self.xmax], data.close.tolist()[:self.xmax],
data.high.tolist()[:self.xmax], data.low.tolist()[:self.xmax],
0.6, 'r', 'g')
self.connect_event('key_release_event', self.keyrelease)
示例6: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, vertex_list, ax, channels, name=None):
AxesWidget.__init__(self, ax)
self.channels = channels
self.name = name
self.region = '?'
self.gate_type = self.__class__.__name__
self._spawned_vertex_list = [vert.spawn(self.ax, channels) for vert in vertex_list]
[svertex.add_callback(self.handle_vertex_event) for svertex in self._spawned_vertex_list]
self.create_artist()
self.activate()
示例7: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, callback=None, useblit=True):
AxesWidget.__init__(self, ax)
self.useblit = useblit and self.canvas.supports_blit
self.verts = []
self.drawing = False
self.line = None
self.callback = callback
self.last_click_time = time.time()
self.connect_event('button_press_event', self.onpress)
self.connect_event('motion_notify_event', self.onmove)
示例8: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, pixels):
AxesWidget.__init__(self, ax)
self.pixels = pixels
self.image = self.ax.imshow(self.pixels,
aspect='auto',
interpolation='none',
vmin=0,
vmax=1)
self.l = None
self.observers = {}
self.cid = 0
示例9: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, radius, **circprops):
AxesWidget.__init__(self, ax)
self.connect_event('motion_notify_event', self.onmove)
self.connect_event('draw_event', self.storebg)
circprops['animated'] = True
circprops['radius'] = radius
self.circ = plt.Circle((0,0), **circprops)
self.ax.add_artist(self.circ)
self.background = None
示例10: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, name, label, valmin, valmax, valinit=0.5, width=1, valfmt='%1.2f',
time_index = None, closedmin=True, closedmax=True, slidermin=None,
slidermax=None, drag_enabled=True, **kwargs):
"""
Create a slider from *valmin* to *valmax* in axes *ax*
*valinit*
The slider initial position
*label*
The slider label
*valfmt*
Used to format the slider value
*closedmin* and *closedmax*
Indicate whether the slider interval is closed
*slidermin* and *slidermax*
Used to constrain the value of this slider to the values
of other sliders.
additional kwargs are passed on to ``self.poly`` which is the
:class:`matplotlib.patches.Rectangle` which draws the slider
knob. See the :class:`matplotlib.patches.Rectangle` documentation
valid property names (e.g., *facecolor*, *edgecolor*, *alpha*, ...)
"""
AxesWidget.__init__(self, ax)
self.label = ax.text(-0.02, 0.5, label, transform=ax.transAxes,
verticalalignment='center',
horizontalalignment='right')
self.valtext = None
self.poly = None
self.reinit(valmin, valmax, valinit, width, valfmt, time_index, **kwargs)
self.name = name
self.cnt = 0
self.closedmin = closedmin
self.closedmax = closedmax
self.slidermin = slidermin
self.slidermax = slidermax
self.drag_active = False
self.drag_enabled = drag_enabled
self.observers = {}
ax.set_yticks([])
#ax.set_xticks([]) # disable ticks
ax.set_navigate(False)
self._connect()
示例11: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, coordinates, ax, callback_list=None):
AxesWidget.__init__(self, ax)
self.add_callback(callback_list)
self.selected = False
self.coordinates = tuple([c if c is not None else 0.5 for c in coordinates]) # Replaces all Nones with 0.5
self.trackx = coordinates[0] is not None
self.tracky = coordinates[1] is not None
if not self.trackx and not self.tracky:
raise Exception('Mode not supported')
self.artist = None
self.create_artist()
self.connect_event('pick_event', lambda event: self.pick(event))
self.connect_event('motion_notify_event', lambda event: self.motion_notify_event(event))
# self.connect_event('button_press_event', lambda event : self.mouse_button_press(event))
self.connect_event('button_release_event', lambda event: self.mouse_button_release(event))
示例12: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, label, image=None, color="0.85", hovercolor="0.95"):
AxesWidget.__init__(self, ax)
if image is not None:
ax.imshow(image)
self.label = ax.text(
0.5, 0.5, label, verticalalignment="center", horizontalalignment="center", transform=ax.transAxes
)
self.cnt = 0
self.observers = {}
self.connect_event("button_press_event", self._click)
self.connect_event("button_release_event", self._release)
self.connect_event("motion_notify_event", self._motion)
ax.set_navigate(False)
ax.set_axis_bgcolor(color)
ax.set_xticks([])
ax.set_yticks([])
self.color = color
self.hovercolor = hovercolor
self._lastcolor = color
示例13: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, s='', allowed_chars=None, type=str, **text_kwargs):
AxesWidget.__init__(self, ax)
self.ax.set_navigate(False)
self.ax.set_yticks([])
self.ax.set_xticks([])
self.type = type
self.allowed_chars = allowed_chars
self.value = self.type(s)
self.text = self.ax.text(0.025, 0.2, s,
transform=self.ax.transAxes, **text_kwargs)
self._cid = None
self._cursor = None
self._cursorpos = len(self.text.get_text())
self.old_callbacks = {}
self.cnt = 0
self.observers = {}
self.exit_cnt = 0
self.exit_observers = {}
self.connect_event('button_press_event', self._mouse_activate)
示例14: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt='%1.2f',
closedmin=True, closedmax=True, slidermin=None, slidermax=None,
dragging=True, **kwargs):
"""
Create a slider from *valmin* to *valmax* in axes *ax*
*valinit*
The slider initial position
*label*
The slider label
*valfmt*
Used to format the slider value
*closedmin* and *closedmax*
Indicate whether the slider interval is closed
*slidermin* and *slidermax*
Used to constrain the value of this slider to the values
of other sliders.
additional kwargs are passed on to ``self.poly`` which is the
:class:`matplotlib.patches.Rectangle` which draws the slider
knob. See the :class:`matplotlib.patches.Rectangle` documentation
valid property names (e.g., *facecolor*, *edgecolor*, *alpha*, ...)
"""
AxesWidget.__init__(self, ax)
self.valmin = valmin
self.valmax = valmax
self.val = valinit
self.valinit = valinit
self.poly = ax.axhspan(valmin,valinit,0,1, **kwargs)
self.hline = ax.axhline(valinit,0,1, color='r', lw=1)
self.valfmt=valfmt
ax.set_yticks([])
ax.set_ylim((valmin, valmax))
ax.set_xticks([])
ax.set_navigate(False)
self.connect_event('button_press_event', self._update)
self.connect_event('button_release_event', self._update)
if dragging:
self.connect_event('motion_notify_event', self._update)
self.label = ax.text(0.5, 1.02, label, transform=ax.transAxes,
verticalalignment='bottom',
horizontalalignment='center')
self.valtext = ax.text(0.5, -0.02, valfmt%valinit,
transform=ax.transAxes,
verticalalignment='top',
horizontalalignment='center')
self.cnt = 0
self.observers = {}
self.closedmin = closedmin
self.closedmax = closedmax
self.slidermin = slidermin
self.slidermax = slidermax
self.drag_active = False
示例15: __init__
# 需要导入模块: from matplotlib.widgets import AxesWidget [as 别名]
# 或者: from matplotlib.widgets.AxesWidget import __init__ [as 别名]
def __init__(self, ax, s='', allowed_chars=None, type=str,
enter_callback=None, **text_kwargs):
"""
Editable text box
Creates a mouse-click callback such that clicking on the text box will
activate the cursor.
*WARNING* Activating a textbox will remove all other key-press
bindings! They'll be stored in TextBox.old_callbacks and restored
when TextBox.end_text_entry() is called.
The default widget assumes only numerical data and will not
allow text entry besides numerical characters and ('e','-','.')
Parameters
----------
*ax* : :class:`matplotlib.axes.Axes`
The parent axes for the widget
*s* : str
The initial text of the TextBox.
*allowed_chars* : seq
TextBox will only respond if event.key in allowed_chars. Defaults
to None, which accepts anything.
*type* : type
Construct self.value using this type. self.value is only updated
if self.type(<text>) succeeds.
*enter_callback* : function
A function of one argument that will be called with
TextBox.value passed in as the only argument when enter is
pressed
*text_kwargs* :
Additional keywork arguments are passed on to self.ax.text()
Call :meth:`on_onchanged` to connect to TextBox updates
"""
AxesWidget.__init__(self, ax)
self.ax.set_navigate(False)
self.ax.set_yticks([])
self.ax.set_xticks([])
self.type = type
self.allowed_chars = allowed_chars
self.value = self.type(s)
self.text = self.ax.text(0.025, 0.2, s,
transform=self.ax.transAxes, **text_kwargs)
self.enter_callback = enter_callback
self._cid = None
self._cursor = None
self._cursorpos = len(self.text.get_text())
self.old_callbacks = {}
self.cnt = 0
self.observers = {}
self.connect_event('button_press_event', self._mouse_activate)