本文整理汇总了Python中matplotlib.widgets.AxesWidget类的典型用法代码示例。如果您正苦于以下问题:Python AxesWidget类的具体用法?Python AxesWidget怎么用?Python AxesWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AxesWidget类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:ehyoo,项目名称:HAMR,代码行数:29,代码来源:my_button.py
示例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)
开发者ID:vodkabuaa,项目名称:QuantDigger,代码行数:25,代码来源:widgets.py
示例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),
开发者ID:OrkoHunter,项目名称:yoink,代码行数:35,代码来源:widgets.py
示例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()
开发者ID:e-sr,项目名称:KG,代码行数:27,代码来源:mpl_widgets.py
示例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())
开发者ID:henryroe,项目名称:ztv,代码行数:31,代码来源:plot_panel.py
示例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)
开发者ID:waltherg,项目名称:yoink,代码行数:29,代码来源:widgets.py
示例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)
开发者ID:adam-urbanczyk,项目名称:cytoflow,代码行数:11,代码来源:matplotlib_widgets.py
示例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()
开发者ID:eyurtsev,项目名称:FlowCytometryTools,代码行数:11,代码来源:fc_widget.py
示例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
开发者ID:aespinosav,项目名称:yoink,代码行数:12,代码来源:widgets.py
示例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
开发者ID:lucasb-eyer,项目名称:laser-detection-annotator,代码行数:13,代码来源:anno1602.py
示例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()
开发者ID:oxmcvusd,项目名称:quantdigger,代码行数:49,代码来源:widgets.py
示例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
开发者ID:henryroe,项目名称:ztv,代码行数:10,代码来源:plot_panel.py
示例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))
开发者ID:ZELLMECHANIK-DRESDEN,项目名称:FlowCytometryTools,代码行数:20,代码来源:fc_widget.py
示例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
开发者ID:wangchr,项目名称:HAMR,代码行数:23,代码来源:matplotlib_subclassed_widgets.py
示例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)
开发者ID:OrkoHunter,项目名称:yoink,代码行数:24,代码来源:textbox.py
示例16: mpl_setup
def mpl_setup(self):
self.axes_widget = AxesWidget(self.figure.gca())
self.axes_widget.connect_event('button_press_event', self.on_click)
self.axes_widget.connect_event('scroll_event', self.on_scroll)
开发者ID:henryroe,项目名称:xatmos,代码行数:4,代码来源:xatmos.py
示例17: PhotPlotPanel
class PhotPlotPanel(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.axes_widget.connect_event('button_press_event', self.on_button_press)
self.axes_widget.connect_event('button_release_event', self.on_button_release)
self.axes_widget.connect_event('figure_leave_event', self.on_cursor_leave)
self.button_down = False
def on_button_press(self, event):
self.aper_names = ['aprad', 'skyradin', 'skyradout']
self.aper_last_radii = np.array([self.ztv_frame.phot_panel.aprad,
self.ztv_frame.phot_panel.skyradin,
self.ztv_frame.phot_panel.skyradout])
self.button_press_xdata = event.xdata
self.cur_aper_index = np.abs(self.aper_last_radii - event.xdata).argmin()
self.cur_aper_name = self.aper_names[self.cur_aper_index]
# but, click must be within +-N pix to be valid
if np.abs(event.xdata - self.aper_last_radii[self.cur_aper_index]) <= 20:
self.button_down = True
def on_motion(self, event):
if self.button_down:
if event.xdata is not None:
if self.cur_aper_name == 'aprad':
self.ztv_frame.phot_panel.aprad = (self.aper_last_radii[self.cur_aper_index] +
(event.xdata - self.button_press_xdata))
self.ztv_frame.phot_panel.aprad_textctrl.SetValue('{0:.2f}'.format(self.ztv_frame.phot_panel.aprad))
set_textctrl_background_color(self.ztv_frame.phot_panel.aprad_textctrl, 'ok')
elif self.cur_aper_name == 'skyradin':
self.ztv_frame.phot_panel.skyradin = (self.aper_last_radii[self.cur_aper_index] +
(event.xdata - self.button_press_xdata))
self.ztv_frame.phot_panel.skyradin_textctrl.SetValue('{0:.2f}'.format(
self.ztv_frame.phot_panel.skyradin))
set_textctrl_background_color(self.ztv_frame.phot_panel.skyradin_textctrl, 'ok')
elif self.cur_aper_name == 'skyradout':
self.ztv_frame.phot_panel.skyradout = (self.aper_last_radii[self.cur_aper_index] +
(event.xdata - self.button_press_xdata))
self.ztv_frame.phot_panel.skyradout_textctrl.SetValue('{0:.2f}'.format(
self.ztv_frame.phot_panel.skyradout))
set_textctrl_background_color(self.ztv_frame.phot_panel.skyradout_textctrl, 'ok')
self.ztv_frame.phot_panel.recalc_phot()
def on_button_release(self, event):
if self.button_down:
if event.xdata is not None:
if self.cur_aper_name == 'aprad':
self.ztv_frame.phot_panel.aprad = (self.aper_last_radii[self.cur_aper_index] +
(event.xdata - self.button_press_xdata))
self.ztv_frame.phot_panel.aprad_textctrl.SetValue('{0:.2f}'.format(self.ztv_frame.phot_panel.aprad))
set_textctrl_background_color(self.ztv_frame.phot_panel.aprad_textctrl, 'ok')
elif self.cur_aper_name == 'skyradin':
self.ztv_frame.phot_panel.skyradin = (self.aper_last_radii[self.cur_aper_index] +
(event.xdata - self.button_press_xdata))
self.ztv_frame.phot_panel.skyradin_textctrl.SetValue('{0:.2f}'.format(
self.ztv_frame.phot_panel.skyradin))
set_textctrl_background_color(self.ztv_frame.phot_panel.skyradin_textctrl, 'ok')
elif self.cur_aper_name == 'skyradout':
self.ztv_frame.phot_panel.skyradout = (self.aper_last_radii[self.cur_aper_index] +
(event.xdata - self.button_press_xdata))
self.ztv_frame.phot_panel.skyradout_textctrl.SetValue('{0:.2f}'.format(
self.ztv_frame.phot_panel.skyradout))
set_textctrl_background_color(self.ztv_frame.phot_panel.skyradout_textctrl, 'ok')
self.ztv_frame.phot_panel.recalc_phot()
self.button_down = False
def on_cursor_leave(self, event):
if self.button_down:
if self.cur_aper_name == 'aprad':
self.ztv_frame.phot_panel.aprad = self.aper_last_radii[self.cur_aper_index]
self.ztv_frame.phot_panel.aprad_textctrl.SetValue('{0:.2f}'.format(self.ztv_frame.phot_panel.aprad))
set_textctrl_background_color(self.ztv_frame.phot_panel.aprad_textctrl, 'ok')
elif self.cur_aper_name == 'skyradin':
self.ztv_frame.phot_panel.skyradin = self.aper_last_radii[self.cur_aper_index]
self.ztv_frame.phot_panel.skyradin_textctrl.SetValue('{0:.2f}'.format(
self.ztv_frame.phot_panel.skyradin))
set_textctrl_background_color(self.ztv_frame.phot_panel.skyradin_textctrl, 'ok')
elif self.cur_aper_name == 'skyradout':
self.ztv_frame.phot_panel.skyradout = self.aper_last_radii[self.cur_aper_index]
self.ztv_frame.phot_panel.skyradout_textctrl.SetValue('{0:.2f}'.format(
self.ztv_frame.phot_panel.skyradout))
set_textctrl_background_color(self.ztv_frame.phot_panel.skyradout_textctrl, 'ok')
self.ztv_frame.phot_panel.recalc_phot()
self.button_down=False
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())
开发者ID:henryroe,项目名称:ztv,代码行数:99,代码来源:phot_panel.py
示例18: __init__
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)
开发者ID:waltherg,项目名称:yoink,代码行数:62,代码来源:textbox.py
示例19: __init__
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
开发者ID:jldmv,项目名称:bband_scripts,代码行数:65,代码来源:fitting_GUI_B_v10.py
示例20: set_active
def set_active(self, active):
AxesWidget.set_active(self, active)
if active:
self.update_background(None)
开发者ID:e-sr,项目名称:KG,代码行数:4,代码来源:mpl_widgets.py
注:本文中的matplotlib.widgets.AxesWidget类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论