• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python artist.setp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.artist.setp函数的典型用法代码示例。如果您正苦于以下问题:Python setp函数的具体用法?Python setp怎么用?Python setp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: colorcycle

def colorcycle(index=None, handles=None):
    '''Return a list of colors used for new lines in the axis.

    index    -- optional integer index for a color from the cycle
                Return complete colorcycle when None.  Return a single
                color when integer.  Return a list of colors when
                iterable.
    handles  -- optional matplotlib object or iterable of objects, whose
                color would be set according to the index.

    Return string or a list of strings.
    '''
    from matplotlib import rcParams
    ccycle = rcParams['axes.color_cycle'][:]
    if index is None:
        rv = ccycle
    elif _isiterablenotstring(index):
        rv = [colorcycle(i) for i in index]
    else:
        nmidx = index % len(ccycle)
        rv = ccycle[nmidx]
    if handles is not None:
        from matplotlib.artist import setp
        if type(rv) is list:
            for c, h in zip(rv, handles):
                setp(h, color=c)
        else:
            setp(handles, color=rv)
        _redraw()
    return rv
开发者ID:CJ-Wright,项目名称:ipython_ophyd,代码行数:30,代码来源:pylab_utilities.py


示例2: __init__

    def __init__(self,
                 edgecolor=None,
                 facecolor=None,
                 linewidth=None,
                 linestyle=None,
                 antialiased = None,
                 hatch = None,
                 fill=True,
                 **kwargs
                 ):
        """
        The following kwarg properties are supported
        %(Patch)s
        """
        artist.Artist.__init__(self)

        if linewidth is None: linewidth = mpl.rcParams['patch.linewidth']
        if linestyle is None: linestyle = "solid"
        if antialiased is None: antialiased = mpl.rcParams['patch.antialiased']

        self.set_edgecolor(edgecolor)
        self.set_facecolor(facecolor)
        self.set_linewidth(linewidth)
        self.set_linestyle(linestyle)
        self.set_antialiased(antialiased)
        self.set_hatch(hatch)
        self.fill = fill
        self._combined_transform = transforms.IdentityTransform()

        if len(kwargs): artist.setp(self, **kwargs)
开发者ID:Einstein-NTE,项目名称:einstein,代码行数:30,代码来源:patches.py


示例3: grid

    def grid(self, b=None, which='major', axis="both", **kwargs):
        """
        Toggle the gridlines, and optionally set the properties of the lines.
        """
        # their are some discrepancy between the behavior of grid in
        # axes_grid and the original mpl's grid, because axes_grid
        # explicitly set the visibility of the gridlines.

        super(Axes, self).grid(b, which=which, axis=axis, **kwargs)
        if not self._axisline_on:
            return

        if b is None:

            if self.axes.xaxis._gridOnMinor or self.axes.xaxis._gridOnMajor or \
                   self.axes.yaxis._gridOnMinor or self.axes.yaxis._gridOnMajor:
                b=True
            else:
                b=False

        self.gridlines.set_which(which)
        self.gridlines.set_axis(axis)
        self.gridlines.set_visible(b)

        if len(kwargs):
            martist.setp(self.gridlines, **kwargs)
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:26,代码来源:axislines.py


示例4: _matplotlib_week_axis_setup

    def _matplotlib_week_axis_setup(self, ax, xmin, xmax, ymin, ymax):
        from matplotlib.dates import DayLocator, DateFormatter
        from matplotlib.artist import setp

        # X axis
        ax.set_xlim((xmin, xmax))
        ax.xaxis.set_major_locator(DayLocator())
        ax.xaxis.set_major_formatter(DateFormatter("%a"))
        ax.xaxis.grid(True, "major")  # XXX - linestyle...

        labels = ax.get_xticklabels()
        setp(labels, rotation=0, fontsize=9)
        for i in labels:
            i.set_horizontalalignment('left')

        # Y axis
        ax.set_ylim((ymin, ymax))
        yrange = range(ymin, ymax + 1)
        yticks = []
        ylabels = []

        # Y tick and label generation is a bit fussy - the intent here is to generate
        # a reasonable set of ticks and labels for various ymax values.  The logic
        # below works reasonably well for graph height ~100 pixels and ymax from 0 to
        # several thousand.

        tickstep = 5            # for large values, steps of 5 are odd (e.g. 35, 70, 105)
        if ymax > 50:
            tickstep = 10
        if ymax > 500:
            tickstep = 100
            
        tickinterval = (ymax + 9) / 10                              # roughly most 10 ticks per small image
        if tickinterval > 1:                                        # if step > 1, round up to nearest tickstep
            tickinterval = (tickinterval + tickstep - 1) / tickstep * tickstep
        if tickinterval <= 1:
            tickinterval = 1                                        # otherwise use step 1 (also handles zero div)

        labelinterval = (ymax + 2) / 3                                                    # roughly 3 labels per small image
        labelinterval = (labelinterval + tickstep - 1) / tickstep * tickstep              # round up to nearest tickstep
        labelinterval = (labelinterval + tickinterval - 1) / tickinterval * tickinterval  # must be a multiple of tick interval!
        if labelinterval <= 0:
            labelinterval = tickinterval                            # sanity
        if labelinterval <= 1:
            labelinterval = 1
            
        ymax_rounded = (ymax + labelinterval - 1) / labelinterval * labelinterval + tickinterval

        # compute actual tick positions and labels
        for i in range(ymin, ymax_rounded + 1, tickinterval):
            yticks.append(i)
            if (int(i) % labelinterval) == 0:
                ylabels.append(str(int(i)))
            else:
                ylabels.append('')
                
        ax.yaxis.set_ticks(yticks)
        ax.yaxis.set_ticklabels(ylabels)
        labels = ax.get_yticklabels()
        setp(labels, rotation=0, fontsize=9)
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:60,代码来源:graphs.py


示例5: _set_ticks_labels

def _set_ticks_labels(ax, data, labels, positions, plot_opts):
    """Set ticks and labels on horizontal axis."""

    # Set xticks and limits.
    ax.set_xlim([np.min(positions) - 0.5, np.max(positions) + 0.5])
    ax.set_xticks(positions)

    label_fontsize = plot_opts.get('label_fontsize')
    label_rotation = plot_opts.get('label_rotation')
    if label_fontsize or label_rotation:
        from matplotlib.artist import setp

    if labels is not None:
        if not len(labels) == len(data):
            msg = "Length of `labels` should equal length of `data`."
            raise(ValueError, msg)

        xticknames = ax.set_xticklabels(labels)
        if label_fontsize:
            setp(xticknames, fontsize=label_fontsize)

        if label_rotation:
            setp(xticknames, rotation=label_rotation)

    return
开发者ID:nell-byler,项目名称:faststats,代码行数:25,代码来源:plot.py


示例6: blanklinemarkers

def blanklinemarkers(lineid, filled=False,
        marker=None, color=None, width=None, **kw):
    '''Clear markerfacecolor for the specified lines and adjust the
    edge width and color according to the owner line.

    lineid   -- integer zero based index or a matplotlib Line2D instance.
                Can be also a list of indices or Line2D objects.
    filled   -- when True, restore the markerfacecolor
    color    -- use instead of line color when specified
    width    -- use for markeredge width if specified, otherwise use
                the line width.
    kw       -- optional keyword arguments for additional line properties

    No return value.
    '''
    from matplotlib.artist import setp
    linehandles = findlines(lineid)
    for hi in linehandles:
        mi = hi.get_marker() if marker is None else marker
        ci = hi.get_color() if color is None else color
        mfc = ci if filled else 'none'
        mec = ci
        mwi = hi.get_linewidth() if width is None else width
        hi.set_marker(mi)
        hi.set_markerfacecolor(mfc)
        hi.set_markeredgecolor(mec)
        hi.set_markeredgewidth(mwi)
        if kw:  setp(hi, **kw)
    if linehandles:
        _redraw()
    return
开发者ID:CJ-Wright,项目名称:ipython_ophyd,代码行数:31,代码来源:pylab_utilities.py


示例7: _plot

def _plot(fig, hists, labels, N, show_ticks=False):
    """
    Plot pair-wise correlation histograms
    """
    if N<=1: 
        fig.text(0.5,0.5,"No correlation plots when only one variable",ha="center",va="center") 
        return
    vmin, vmax = inf, -inf
    for data,_,_ in hists.values():
        positive = data[data>0]
        if len(positive) > 0:
            vmin = min(vmin,numpy.amin(positive))
            vmax = max(vmax,numpy.amax(positive))
    norm = colors.LogNorm(vmin=vmin, vmax=vmax, clip=False)
    #norm = colors.Normalize(vmin=vmin, vmax=vmax)
    mapper = image.FigureImage(fig)
    mapper.set_array(numpy.zeros(0))
    mapper.set_cmap(cmap=COLORMAP)
    mapper.set_norm(norm)

    ax = {}
    Nr = Nc = N-1
    for i in range(0,N-1):
        for j in range(i+1,N):
            sharex = ax.get((0,j), None)
            sharey = ax.get((i,i+1), None)
            a = fig.add_subplot(Nr,Nc,(Nr-i-1)*Nc + j,
                                sharex=sharex, sharey=sharey)
            ax[(i,j)] = a
            a.xaxis.set_major_locator(MaxNLocator(4,steps=[1,2,4,5,10]))
            a.yaxis.set_major_locator(MaxNLocator(4,steps=[1,2,4,5,10]))
            data,x,y = hists[(i,j)]
            data = numpy.clip(data,vmin,vmax)
            a.pcolorfast(y,x,data,cmap=COLORMAP,norm=norm)
            # Show labels or hide ticks
            if i != 0:
                artist.setp(a.get_xticklabels(),visible=False)
            if i == N-2 and j == N-1:
                a.set_xlabel(labels[j])
                #a.xaxis.set_label_position("top")
                #a.xaxis.set_offset_position("top")
            if not show_ticks:
                a.xaxis.set_ticks([])
            if j == i+1:
                a.set_ylabel(labels[i])
            else:
                artist.setp(a.get_yticklabels(),visible=False)
            if not show_ticks:
                a.yaxis.set_ticks([])

            a.zoomable=True


    # Adjust subplots and add the colorbar
    fig.subplots_adjust(left=.07, bottom=.07, top=.9, right=0.85,
                        wspace=0.0, hspace=0.0)
    cax = fig.add_axes([0.88, 0.2, 0.04, 0.6])
    fig.colorbar(mapper, cax=cax, orientation='vertical')
    return ax
开发者ID:RONNCC,项目名称:bumps,代码行数:59,代码来源:corrplot.py


示例8: _show_legend

def _show_legend(ax):
    """Utility function to show legend."""
    leg = ax.legend(loc=1, shadow=True, fancybox=True, labelspacing=0.2,
                    borderpad=0.15)
    ltext  = leg.get_texts()
    llines = leg.get_lines()

    from matplotlib.artist import setp
    setp(ltext, fontsize='small')
    setp(llines, linewidth=1)
开发者ID:nell-byler,项目名称:faststats,代码行数:10,代码来源:plot.py


示例9: animate_function

	def animate_function(i):
		global a
		if a<time_steps:
			line.set_data(X, Array[i,:])
			setp(line, linewidth=2, color='r')
			# line = Line2D(X, Array[:,i], color='red', linewidth=2)
		else:
			line.set_data(X, Array[-1,:])
		a+=1
		
		return line
开发者ID:byuimpactrevisions,项目名称:numerical_computing,代码行数:11,代码来源:solution.py


示例10: changeStyle

    def changeStyle(self, curveRef, style):
        """change curve style

        curveRef -- internal reference to curves
        style -- style dictionary
        """
        stylestr, properties = self.__translateStyles(style)
        #FIXME: we discard stylestr because it seems there's no way
        # it can be changed afterwards.
        setp((curveRef,), **properties)
        self.subplot.legend(**legendBoxProperties())
开发者ID:diffpy,项目名称:diffpy.pdfgui,代码行数:11,代码来源:extendedplotframe.py


示例11: test_setp

def test_setp():
    # Check arbitrary iterables
    fig, axes = plt.subplots()
    lines1 = axes.plot(range(3))
    lines2 = axes.plot(range(3))
    martist.setp(chain(lines1, lines2), 'lw', 5)
    plt.setp(axes.spines.values(), color='green')

    # Check `file` argument
    sio = io.StringIO()
    plt.setp(lines1, 'zorder', file=sio)
    assert sio.getvalue() == '  zorder: any number \n'
开发者ID:4over7,项目名称:matplotlib,代码行数:12,代码来源:test_artist.py


示例12: animate_function

    def animate_function(i):
        global a
        if i == 0:
            time.sleep(0.3)
        if a < time_steps:
            lines[1].set_data(X, Array[i, :])
            setp(lines[1], linewidth=2.6, color="k")
        else:
            lines[1].set_data(X, Array[-1, :])

        a += 1

        return lines
开发者ID:jmorrise,项目名称:Labs,代码行数:13,代码来源:solution.py


示例13: show

    def show(self, hardrefresh=True):
        """
        Show graphics dependent on the current buffering state.
        """
        if not hardrefresh: return
        if not self.buffering:
            if self.loc is not None:
                for sp in self.subplots:
                    lines  = []
                    labels = []
                    i = 0
                    for line in sp['lines']:
                        i += 1
                        if line is not None:
                            lines.append(line[0])
                            lbl = line[0].get_label()
                            if lbl == '':
                                lbl = str(i)
                            labels.append(lbl)

                    if len(lines):
                        fp = FP(size=rcParams['legend.fontsize'])
                        #fsz = fp.get_size_in_points() - len(lines)
                        fsz = fp.get_size_in_points() - max(len(lines),self.cols)
                        #fp.set_size(max(fsz,6))
                        fp.set_size(max(fsz,8))
                        sp['axes'].legend(tuple(lines), tuple(labels),
                                          self.loc, prop=fp)
                    #else:
                    #    sp['axes'].legend((' '))

            from matplotlib.artist import setp
            fpx = FP(size=rcParams['xtick.labelsize'])
            xts = fpx.get_size_in_points()- (self.cols)/2
            fpy = FP(size=rcParams['ytick.labelsize'])
            yts = fpy.get_size_in_points() - (self.rows)/2
            fpa = FP(size=rcParams['axes.labelsize'])
            fpat = FP(size=rcParams['axes.titlesize'])
            axsize =  fpa.get_size_in_points()
            tsize =  fpat.get_size_in_points()-(self.cols)/2
            for sp in self.subplots:
                ax = sp['axes']
                ax.title.set_size(tsize)
                setp(ax.get_xticklabels(), fontsize=xts)
                setp(ax.get_yticklabels(), fontsize=yts)
                off = 0
                if self.cols > 1: off = self.cols
                ax.xaxis.label.set_size(axsize-off)
                off = 0
                if self.rows > 1: off = self.rows
                ax.yaxis.label.set_size(axsize-off)
开发者ID:schiebel,项目名称:casa,代码行数:51,代码来源:asaplotbase.py


示例14: cla

    def cla(self):
        super().cla()

        martist.setp(self.get_children(), visible=False)
        self._get_lines = self._parent_axes._get_lines

        # In mpl's Axes, zorders of x- and y-axis are originally set
        # within Axes.draw().
        if self._axisbelow:
            self.xaxis.set_zorder(0.5)
            self.yaxis.set_zorder(0.5)
        else:
            self.xaxis.set_zorder(2.5)
            self.yaxis.set_zorder(2.5)
开发者ID:mattip,项目名称:matplotlib,代码行数:14,代码来源:parasite_axes.py


示例15: plot

 def plot(self, windir, windspeed, windfrequency):
     self.windir = []
     self.windspeed = []
     
     for i, frequency in enumerate(windfrequency):
         for n in range(frequency):
             self.windir.append(windir[i])
             self.windspeed.append(windspeed[i])
     
     self.axes.clear()
     self.axes.bar(self.windir, self.windspeed, normed=True, opening=0.8, edgecolor='white')
     l = self.axes.legend(borderaxespad=-3.8)
     setp(l.get_texts(), fontsize=8)
     
     # force redraw the canvas
     self.fig.canvas.draw()
开发者ID:arifwn,项目名称:thorn,代码行数:16,代码来源:thorn.py


示例16: render

    def render(self, axes, x, y):
        color = axes._get_lines.color_cycle

        axes.scatter(x, y, color=color.next(), s=3)
        axes.set_aspect('equal')

        divider = make_axes_locatable(axes)
        axesTop = divider.append_axes('top', 1.2, pad=0.1, sharex=axes)
        axesRight = divider.append_axes('right', 1.2, pad=0.2, sharey=axes)

        # Make labels invisible:
        setp(axesTop.get_xticklabels() + axesRight.get_yticklabels(),
                    visible=False)

        axesTop.hist(x, bins=20, fc='k', ec=None, normed=True)
        axesRight.hist(y, bins=20, fc='k', ec=None, orientation='horizontal', normed=True)
        [t.set_rotation(-90) for t in axesRight.get_xticklabels()]
开发者ID:HyeonJeongKim,项目名称:tcrm,代码行数:17,代码来源:figures.py


示例17: update_legend

    def update_legend(self):
        Util.debug(1, "ScatterPlot.update_legend", "")

        if self.get('legend').get('loc') == 'none' or self.plot() == None or self.plot().axes() == None:
            return
        
        # We need to apply the font dict to the Text instances themselves, since
        # Legend only accepts a FontProperties object
        legendOptions = self.getMpl('legend')
        font = legendOptions['font']
        titleFont = legendOptions['titleFont']
        del legendOptions['font']
        del legendOptions['titleFont']

        self.plot().axes().legend(**legendOptions)

        setp(self.plot().axes().get_legend().get_texts(), **font)
        setp(self.plot().axes().get_legend().get_title(), **titleFont)

        self.plot().redraw()
开发者ID:bbreslauer,项目名称:PySciPlot,代码行数:20,代码来源:Plot.py


示例18: main

def main():
    if len(sys.argv) == 1: f = 'data/he10_2013_1225_214621.dat'
    else: f = sys.argv[1]
    d1 = plot_temps.format_he10_data(f)
    d2 = plot_temps.format_he10_data(f)
    # plot
    fig = plt.figure()
    ax1 = plt.subplot2grid((1, 2), (0, 0))
    ax2 = plt.subplot2grid((1, 2), (0, 1))
    plot_temps.plot_he10_data(ax1, *d1)
    plot_temps.plot_he10_data(ax2, *d2)
    # range
    x1min = dt.datetime(2014, 1, 1)
    x1max = dt.datetime(2014, 1, 8)
    x2min = dt.datetime(2014, 1, 11)
    x2max = dt.datetime(2014, 1, 18)
    ax1.set_xlim(x1min, x1max)
    ax2.set_xlim(x2min, x2max)
    # tune
    ax1.grid()
    ax1.grid(which='minor')
    ax2.grid()
    ax2.grid(which='minor')
    ax1.semilogy()
    ax2.semilogy()
    plt.subplots_adjust(wspace=0.05)
    ax1.set_ylabel('Temperature [K]', fontsize=15)
    ma.setp(ax2.get_yticklabels(), visible=False)
    daysLoc1 = md.DayLocator(interval=2)
    daysLoc2 = md.DayLocator(interval=2)
    ax1.xaxis.set_major_locator(daysLoc1)
    ax2.xaxis.set_major_locator(daysLoc2)
    plt.legend(ncol=3, bbox_to_anchor=[0.92, 1.0])
    xfmt = md.DateFormatter('%b.%d')
    ax1.xaxis.set_major_formatter(xfmt)
    ax2.xaxis.set_major_formatter(xfmt)
    ax1.set_title('Rotation with 20 rpm', fontsize=15)
    ax2.set_title('No rotaion', fontsize=15)
    plt.savefig("eps/comp_temps.eps")
    plt.show()
开发者ID:groundbird,项目名称:he10_plotter,代码行数:40,代码来源:plot_temp_comp.py


示例19: formatting

    def formatting(self):
        ax1, ax2 = self.ax1, self.ax2
        ax1.grid(True, color=self.theme['grid'], alpha=0.5)
        ax2.grid(True, color=self.theme['grid'], alpha=0.5)

        for region in ['bottom', 'top', 'left', 'right']:
            ax1.spines[region].set_color(self.theme['spines'])
            ax2.spines[region].set_color(self.theme['spines'])

        ax1.tick_params(axis='x', colors=self.theme['ticks'])
        ax2.tick_params(axis='x', colors=self.theme['ticks'])
        ax1.tick_params(axis='y', colors=self.theme['ticks'])
        ax2.tick_params(axis='y', colors=self.theme['ticks'])

        ax1.xaxis.label.set_color(self.theme['labels'])
        ax2.xaxis.label.set_color(self.theme['labels'])
        ax1.yaxis.label.set_color(self.theme['labels'])
        ax2.yaxis.label.set_color(self.theme['labels'])

        ax1.set_ylabel('USD/BTC')

        # hide x labels of upper subplot
        setp(ax1.get_xticklabels(), visible=False)
开发者ID:AdamStone,项目名称:cryptrade,代码行数:23,代码来源:plotting.py


示例20: box_plot

  def box_plot(self):
    data = dict()
    for key, value in self.args.data.items():
      if value['type_0_tx'] < MIN_PKT_COUNT:
        continue
      k = self.get_key(key[0], key[1], key[2])
      if k is None:
        continue
      k = '%.2f' % (k)
      if k not in data:
        data[k] = []
      v = self.get_value(value)
      if v is not None:
        data[k].append(v)

    data = self.post_process(data)

    ax = self.add_subplot(111)
    X = sorted(data.keys(), key=lambda t: float(t))
    Y = [data[x] for x in X]
    lines = ax.boxplot(Y, sym='', whis=[10, 90], widths=0.4, patch_artist=True)

    setp(lines['medians'], color='k', linewidth=1)
    setp(lines['boxes'], color='grey', linewidth=0.5)
    setp(lines['whiskers'], linewidth=0.5, color='grey', linestyle='solid')
    setp(lines['caps'], linewidth=0.5, color='grey')

    xmax = max([float(x) for x in X])
    if xmax > 1:
      step = 0.5
    else:
      step = 0.1

    xticks = [X.index('%.2f' % (x))+1 for x in np.arange(0, xmax+0.01, step)]
    ax.set_xticks(xticks)
    ax.set_xticklabels(['%.1f' % (x) for x in np.arange(0, xmax+0.01, step)])

    ax.set_xlabel(self.xlabel)
    ax.set_ylabel(self.ylabel)
    return ax
开发者ID:blue-systems-group,项目名称:papers.rv16-verification,代码行数:40,代码来源:plot.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python artist.Artist类代码示例发布时间:2022-05-27
下一篇:
Python artist.kwdoc函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap