本文整理汇总了Python中matplotlib.widgets.AxesWidget类的典型用法代码示例。如果您正苦于以下问题:Python AxesWidget类的具体用法?Python AxesWidget怎么用?Python AxesWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AxesWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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
示例2: __init__
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)
示例3: __init__
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),
示例4: __init__
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()
示例5: PlotPlotPanel
class PlotPlotPanel(wx.Panel):
def __init__(self, parent, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, **kwargs)
self.ztv_frame = self.GetTopLevelParent()
self.figure = Figure(dpi=None, figsize=(1.,1.))
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
self.Bind(wx.EVT_SIZE, self._onSize)
self.axes_widget = AxesWidget(self.figure.gca())
self.axes_widget.connect_event('motion_notify_event', self.on_motion)
self.plot_point = None
def on_motion(self, evt):
if evt.xdata is not None:
xarg = np.abs(self.ztv_frame.plot_panel.plot_positions - evt.xdata).argmin()
ydata = self.ztv_frame.plot_panel.plot_im_values[xarg]
self.ztv_frame.plot_panel.cursor_position_textctrl.SetValue('{0:.6g},{1:.6g}'.format(evt.xdata, ydata))
if self.plot_point is None:
self.plot_point, = self.axes.plot([evt.xdata], [ydata], 'xm')
else:
self.plot_point.set_data([[evt.xdata], [ydata]])
self.figure.canvas.draw()
def _onSize(self, event):
self._SetSize()
def _SetSize(self):
pixels = tuple(self.GetClientSize())
self.SetSize(pixels)
self.canvas.SetSize(pixels)
self.figure.set_size_inches(float(pixels[0])/self.figure.get_dpi(), float(pixels[1])/self.figure.get_dpi())
示例6: __init__
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)
示例7: __init__
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__
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()
示例9: __init__
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
示例10: __init__
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
示例11: __init__
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()
示例12: __init__
def __init__(self, parent, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, **kwargs)
self.ztv_frame = self.GetTopLevelParent()
self.figure = Figure(dpi=None, figsize=(1.,1.))
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
self.Bind(wx.EVT_SIZE, self._onSize)
self.axes_widget = AxesWidget(self.figure.gca())
self.axes_widget.connect_event('motion_notify_event', self.on_motion)
self.plot_point = None
示例13: __init__
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))
示例14: __init__
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
示例15: __init__
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)