当前位置: 首页>>代码示例>>Python>>正文


Python AxesWidget.__init__方法代码示例

本文整理汇总了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()
开发者ID:e-sr,项目名称:KG,代码行数:29,代码来源:mpl_widgets.py

示例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
开发者ID:ehyoo,项目名称:HAMR,代码行数:31,代码来源:my_button.py

示例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)
开发者ID:waltherg,项目名称:yoink,代码行数:31,代码来源:widgets.py

示例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),
开发者ID:OrkoHunter,项目名称:yoink,代码行数:37,代码来源:widgets.py

示例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)
开发者ID:vodkabuaa,项目名称:QuantDigger,代码行数:27,代码来源:widgets.py

示例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()
开发者ID:eyurtsev,项目名称:FlowCytometryTools,代码行数:13,代码来源:fc_widget.py

示例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)
开发者ID:adam-urbanczyk,项目名称:cytoflow,代码行数:13,代码来源:matplotlib_widgets.py

示例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
开发者ID:aespinosav,项目名称:yoink,代码行数:14,代码来源:widgets.py

示例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
开发者ID:lucasb-eyer,项目名称:laser-detection-annotator,代码行数:15,代码来源:anno1602.py

示例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()
开发者ID:oxmcvusd,项目名称:quantdigger,代码行数:51,代码来源:widgets.py

示例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))
开发者ID:ZELLMECHANIK-DRESDEN,项目名称:FlowCytometryTools,代码行数:22,代码来源:fc_widget.py

示例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
开发者ID:wangchr,项目名称:HAMR,代码行数:25,代码来源:matplotlib_subclassed_widgets.py

示例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)
开发者ID:OrkoHunter,项目名称:yoink,代码行数:26,代码来源:textbox.py

示例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
开发者ID:jldmv,项目名称:bband_scripts,代码行数:67,代码来源:fitting_GUI_B_v10.py

示例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)
开发者ID:waltherg,项目名称:yoink,代码行数:64,代码来源:textbox.py


注:本文中的matplotlib.widgets.AxesWidget.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。