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


Python matplotlib.widgets方法代码示例

本文整理汇总了Python中matplotlib.widgets方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.widgets方法的具体用法?Python matplotlib.widgets怎么用?Python matplotlib.widgets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.widgets方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _update

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def _update(self):
        'update the active line props from the widgets'
        if not self._inited or not self._updateson: return
        line = self.get_active_line()
        ls = self.get_active_linestyle()
        marker = self.get_active_marker()
        line.set_linestyle(ls)
        line.set_marker(marker)

        button = self.wtree.get_widget('colorbutton_linestyle')
        color = button.get_color()
        r, g, b = [val/65535. for val in (color.red, color.green, color.blue)]
        line.set_color((r,g,b))

        button = self.wtree.get_widget('colorbutton_markerface')
        color = button.get_color()
        r, g, b = [val/65535. for val in (color.red, color.green, color.blue)]
        line.set_markerfacecolor((r,g,b))

        line.figure.canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:backend_gtk.py

示例2: on_combobox_lineprops_changed

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def on_combobox_lineprops_changed(self, item):
        'update the widgets from the active line'
        if not self._inited: return
        self._updateson = False
        line = self.get_active_line()

        ls = line.get_linestyle()
        if ls is None: ls = 'None'
        self.cbox_linestyles.set_active(self.linestyled[ls])

        marker = line.get_marker()
        if marker is None: marker = 'None'
        self.cbox_markers.set_active(self.markerd[marker])

        r,g,b = colorConverter.to_rgb(line.get_color())
        color = gtk.gdk.Color(*[int(val*65535) for val in (r,g,b)])
        button = self.wtree.get_widget('colorbutton_linestyle')
        button.set_color(color)

        r,g,b = colorConverter.to_rgb(line.get_markerfacecolor())
        color = gtk.gdk.Color(*[int(val*65535) for val in (r,g,b)])
        button = self.wtree.get_widget('colorbutton_markerface')
        button.set_color(color)
        self._updateson = True 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:backend_gtk.py

示例3: _update

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def _update(self):
        'update the active line props from the widgets'
        if not self._inited or not self._updateson: return
        line = self.get_active_line()
        ls = self.get_active_linestyle()
        marker = self.get_active_marker()
        line.set_linestyle(ls)
        line.set_marker(marker)

        button = self.wtree.get_widget('colorbutton_linestyle')
        color = button.get_color()
        r, g, b = [val/65535. for val in color.red, color.green, color.blue]
        line.set_color((r,g,b))

        button = self.wtree.get_widget('colorbutton_markerface')
        color = button.get_color()
        r, g, b = [val/65535. for val in color.red, color.green, color.blue]
        line.set_markerfacecolor((r,g,b))

        line.figure.canvas.draw() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:backend_gtk3.py

示例4: subplot_tool

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def subplot_tool(targetfig=None):
    """
    Launch a subplot tool window for a figure.

    A :class:`matplotlib.widgets.SubplotTool` instance is returned.
    """
    tbar = rcParams['toolbar'] # turn off the navigation toolbar for the toolfig
    rcParams['toolbar'] = 'None'
    if targetfig is None:
        manager = get_current_fig_manager()
        targetfig = manager.canvas.figure
    else:
        # find the manager for this figure
        for manager in _pylab_helpers.Gcf._activeQue:
            if manager.canvas.figure==targetfig: break
        else: raise RuntimeError('Could not find manager for targetfig')

    toolfig = figure(figsize=(6,3))
    toolfig.subplots_adjust(top=0.9)
    ret =  SubplotTool(targetfig, toolfig)
    rcParams['toolbar'] = tbar
    _pylab_helpers.Gcf.set_active(manager)  # restore the current figure
    return ret 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:pyplot.py

示例5: __init__

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def __init__(self, rect, wtype, *args, **kwargs):
        """
        Creates a matplotlib.widgets widget
        :param rect: The rectangle of the position [left, bottom, width, height] in relative figure coordinates
        :param wtype: A type from matplotlib.widgets, eg. Button, Slider, TextBox, RadioButtons
        :param args: Positional arguments passed to the widget
        :param kwargs: Keyword arguments passed to the widget and events used for the widget
                       eg. if wtype is Slider, on_changed=f can be used as keyword argument

        """
        self.ax = plt.axes(rect)
        events = {}
        for k in list(kwargs.keys()):
            if k.startswith('on_'):
                events[k] = kwargs.pop(k)
        self.object = wtype(self.ax, *args, **kwargs)
        for k in events:
            if hasattr(self.object, k):
                getattr(self.object, k)(events[k]) 
开发者ID:thouska,项目名称:spotpy,代码行数:21,代码来源:mpl.py

示例6: subplot_tool

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def subplot_tool(targetfig=None):
    """
    Launch a subplot tool window for a figure.

    A :class:`matplotlib.widgets.SubplotTool` instance is returned.
    """
    tbar = rcParams['toolbar'] # turn off the navigation toolbar for the toolfig
    rcParams['toolbar'] = 'None'
    if targetfig is None:
        manager = get_current_fig_manager()
        targetfig = manager.canvas.figure
    else:
        # find the manager for this figure
        for manager in _pylab_helpers.Gcf._activeQue:
            if manager.canvas.figure == targetfig:
                break
        else:
            raise RuntimeError('Could not find manager for targetfig')

    toolfig = figure(figsize=(6,3))
    toolfig.subplots_adjust(top=0.9)
    ret =  SubplotTool(targetfig, toolfig)
    rcParams['toolbar'] = tbar
    _pylab_helpers.Gcf.set_active(manager)  # restore the current figure
    return ret 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:27,代码来源:pyplot.py

示例7: create_button

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def create_button(idx_feature):
    """ function to built button groups for one feature """
    x, y, w, h = get_loc_control(idx_feature)

    plt.text(x+w/2, y+h/2+0.01, feature_name[idx_feature], horizontalalignment='center',
             transform=plt.gcf().transFigure)

    ax_neg = plt.axes((x + w / 8, y, w / 4, h / 2))
    b_neg = widgets.Button(ax_neg, '-', hovercolor='0.1')
    b_neg.on_clicked(lambda event:
                     callback.modify_along_feature(event, idx_feature, step_size=-1 * step_size))

    ax_pos = plt.axes((x + w *5/8, y, w / 4, h / 2))
    b_pos = widgets.Button(ax_pos, '+', hovercolor='0.1')
    b_pos.on_clicked(lambda event:
                     callback.modify_along_feature(event, idx_feature, step_size=+1 * step_size))

    ax_lock = plt.axes((x + w * 3/8, y, w / 4, h / 2))
    b_lock = widgets.CheckButtons(ax_lock, ['L'], [False])
    b_lock.on_clicked(lambda event:
                      callback.set_feature_lock(event, idx_feature))
    return b_neg, b_pos, b_lock 
开发者ID:SummitKwan,项目名称:transparent_latent_gan,代码行数:24,代码来源:script_generation_interactive.py

示例8: label_shifter

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def label_shifter(n, kw):
    """
    Interprets label shift instructions

    :param n: int
        Number of labels that need shift instructions

    :param kw: dict
        Keywords passed to main plot script; label shifting keywords will be removed

    :return: (1D array with length >= n, 1D array with length >= n)
        R shifts
        Z shifts
    """
    label_dr = kw.pop('label_r_shift', 0)
    label_dz = kw.pop('label_z_shift', 0)
    label_dr = padded_extension(label_dr, n, fill_value=label_dr if numpy.isscalar(label_dr) else 0)
    label_dz = padded_extension(label_dz, n, fill_value=label_dz if numpy.isscalar(label_dz) else 0)
    return label_dr, label_dz


# hold last 100 references of matplotlib.widgets.Slider 
开发者ID:gafusion,项目名称:omas,代码行数:24,代码来源:omas_plot.py

示例9: on_button_multicursor

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def on_button_multicursor(self, event):
        from matplotlib.widgets import MultiCursor

        axes = self.canvas.figure.axes
        if event.IsChecked() and not self.multicursor and axes:
            # add multicursor
            self.multicursor = MultiCursor(self.canvas, axes, color='r', lw=1, horizOn=True, vertOn=True)
        elif self.multicursor:
            # remove multicursor
            self.multicursor.disconnect()
            self.multicursor = None
        self.canvas.draw()
        event.Skip()

    ####################################################################################################################
    # draw elements on canvas plot areas / axes (by coordinates) 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:18,代码来源:matplotlib_example.py

示例10: subplot_tool

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def subplot_tool(targetfig=None):
    """
    Launch a subplot tool window for a figure.

    A :class:`matplotlib.widgets.SubplotTool` instance is returned.
    """
    tbar = rcParams['toolbar']  # turn off navigation toolbar for the toolfig
    rcParams['toolbar'] = 'None'
    if targetfig is None:
        manager = get_current_fig_manager()
        targetfig = manager.canvas.figure
    else:
        # find the manager for this figure
        for manager in _pylab_helpers.Gcf._activeQue:
            if manager.canvas.figure == targetfig:
                break
        else:
            raise RuntimeError('Could not find manager for targetfig')

    toolfig = figure(figsize=(6, 3))
    toolfig.subplots_adjust(top=0.9)
    ret = SubplotTool(targetfig, toolfig)
    rcParams['toolbar'] = tbar
    _pylab_helpers.Gcf.set_active(manager)  # restore the current figure
    return ret 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:27,代码来源:pyplot.py

示例11: on_combobox_lineprops_changed

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def on_combobox_lineprops_changed(self, item):
        'update the widgets from the active line'
        if not self._inited: return
        self._updateson = False
        line = self.get_active_line()

        ls = line.get_linestyle()
        if ls is None: ls = 'None'
        self.cbox_linestyles.set_active(self.linestyled[ls])

        marker = line.get_marker()
        if marker is None: marker = 'None'
        self.cbox_markers.set_active(self.markerd[marker])

        rgba = mcolors.to_rgba(line.get_color())
        color = gtk.gdk.Color(*[int(val*65535) for val in rgba[:3]])
        button = self.wtree.get_widget('colorbutton_linestyle')
        button.set_color(color)

        rgba = mcolors.to_rgba(line.get_markerfacecolor())
        color = gtk.gdk.Color(*[int(val*65535) for val in rgba[:3]])
        button = self.wtree.get_widget('colorbutton_markerface')
        button.set_color(color)
        self._updateson = True 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:26,代码来源:backend_gtk.py

示例12: __init__

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def __init__(self, lines):
        import gtk.glade

        datadir = matplotlib.get_data_path()
        gladefile = os.path.join(datadir, 'lineprops.glade')
        if not os.path.exists(gladefile):
            raise IOError('Could not find gladefile lineprops.glade in %s'%datadir)

        self._inited = False
        self._updateson = True # suppress updates when setting widgets manually
        self.wtree = gtk.glade.XML(gladefile, 'dialog_lineprops')
        self.wtree.signal_autoconnect(dict([(s, getattr(self, s)) for s in self.signals]))

        self.dlg = self.wtree.get_widget('dialog_lineprops')

        self.lines = lines

        cbox = self.wtree.get_widget('combobox_lineprops')
        cbox.set_active(0)
        self.cbox_lineprops = cbox

        cbox = self.wtree.get_widget('combobox_linestyles')
        for ls in self.linestyles:
            cbox.append_text(ls)
        cbox.set_active(0)
        self.cbox_linestyles = cbox

        cbox = self.wtree.get_widget('combobox_markers')
        for m in self.markers:
            cbox.append_text(m)
        cbox.set_active(0)
        self.cbox_markers = cbox
        self._lastcnt = 0
        self._inited = True 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:36,代码来源:backend_gtk.py

示例13: __init__

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import widgets [as 别名]
def __init__(self, lines):
        import Gtk.glade

        datadir = matplotlib.get_data_path()
        gladefile = os.path.join(datadir, 'lineprops.glade')
        if not os.path.exists(gladefile):
            raise IOError('Could not find gladefile lineprops.glade in %s'%datadir)

        self._inited = False
        self._updateson = True # suppress updates when setting widgets manually
        self.wtree = Gtk.glade.XML(gladefile, 'dialog_lineprops')
        self.wtree.signal_autoconnect(dict([(s, getattr(self, s)) for s in self.signals]))

        self.dlg = self.wtree.get_widget('dialog_lineprops')

        self.lines = lines

        cbox = self.wtree.get_widget('combobox_lineprops')
        cbox.set_active(0)
        self.cbox_lineprops = cbox

        cbox = self.wtree.get_widget('combobox_linestyles')
        for ls in self.linestyles:
            cbox.append_text(ls)
        cbox.set_active(0)
        self.cbox_linestyles = cbox

        cbox = self.wtree.get_widget('combobox_markers')
        for m in self.markers:
            cbox.append_text(m)
        cbox.set_active(0)
        self.cbox_markers = cbox
        self._lastcnt = 0
        self._inited = True 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:36,代码来源:backend_gtk3.py


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