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


Python pylab.setp方法代码示例

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


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

示例1: set_all_line_attributes

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def set_all_line_attributes(attribute="lw", value=2, axes="current", refresh=True):
    """

    This function sets all the specified line attributes.

    """

    if axes=="current": axes = _pylab.gca()

    # get the lines from the plot
    lines = axes.get_lines()

    # loop over the lines and trim the data
    for line in lines:
        if isinstance(line, _mpl.lines.Line2D):
            _pylab.setp(line, attribute, value)

    # update the plot
    if refresh: _pylab.draw() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:21,代码来源:_pylab_tweaks.py

示例2: plot_read_count_dists

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def plot_read_count_dists(counts, h=8, n=50):
    """Boxplots of read count distributions """

    scols,ncols = base.get_column_names(counts)
    df = counts.sort_values(by='mean_norm',ascending=False)[:n]
    df = df.set_index('name')[ncols]
    t = df.T
    w = int(h*(len(df)/60.0))+4
    fig, ax = plt.subplots(figsize=(w,h))
    if len(scols) > 1:
        sns.stripplot(data=t,linewidth=1.0,palette='coolwarm_r')
        ax.xaxis.grid(True)
    else:
        df.plot(kind='bar',ax=ax)
    sns.despine(offset=10,trim=True)
    ax.set_yscale('log')
    plt.setp(ax.xaxis.get_majorticklabels(), rotation=90)
    plt.ylabel('read count')
    #print (df.index)
    #plt.tight_layout()
    fig.subplots_adjust(bottom=0.2,top=0.9)
    return fig 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:24,代码来源:plotting.py

示例3: __init__

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def __init__(self, norder = 2):
		"""Initializes the class when returning an instance. Pass it the polynomial order. It will 
set up two figure windows, one for the graph the other for the coefficent interface. It will then initialize 
the coefficients to zero and plot the (not so interesting) polynomial."""
		
		self.order = norder
		
		self.c = M.zeros(self.order,'f')
		self.ax = [None]*(self.order-1)#M.zeros(self.order-1,'i') #Coefficent axes
		
		self.ffig = M.figure() #The first figure window has the plot
		self.replotf()
		
		self.cfig = M.figure() #The second figure window has the 
		row = M.ceil(M.sqrt(self.order-1))
		for n in xrange(self.order-1):
			self.ax[n] = M.subplot(row, row, n+1)
			M.setp(self.ax[n],'label', n)
			M.plot([0],[0],'.')
			M.axis([-1, 1, -1, 1]);
			
		self.replotc()
		M.connect('button_press_event', self.click_event) 
开发者ID:ActiveState,项目名称:code,代码行数:25,代码来源:recipe-576501.py

示例4: init_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def init_plot(self):
        self.dpi = 100
        self.fig = Figure((3.0, 3.0), dpi=self.dpi)

        self.axes = self.fig.add_subplot(111)
        self.axes.set_axis_bgcolor('black')
        self.axes.set_title('Very important random data', size=12)
        
        pylab.setp(self.axes.get_xticklabels(), fontsize=8)
        pylab.setp(self.axes.get_yticklabels(), fontsize=8)

        # plot the data as a line series, and save the reference 
        # to the plotted line series
        #
        self.plot_data = self.axes.plot(
            self.data, 
            linewidth=1,
            color=(1, 1, 0),
            )[0] 
开发者ID:eliben,项目名称:code-for-blog,代码行数:21,代码来源:wx_mpl_dynamic_graph.py

示例5: set_line_attribute

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def set_line_attribute(line=-1, attribute="lw", value=2, axes="current", refresh=True):
    """

    This function sets all the specified line attributes.

    """

    if axes=="current": axes = _pylab.gca()

    # get the lines from the plot
    line = axes.get_lines()[-1]
    _pylab.setp(line, attribute, value)

    # update the plot
    if refresh: _pylab.draw() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:17,代码来源:_pylab_tweaks.py

示例6: expression_clustermap

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def expression_clustermap(counts, freq=0.8):

    scols,ncols = base.get_column_names(counts)
    X = counts.set_index('name')[ncols]
    X = np.log(X)
    v = X.std(1).sort_values(ascending=False)
    X = X[X.isnull().sum(1)/len(X.columns)<0.2]
    X = X.fillna(0)
    cg = sns.clustermap(X,cmap='YlGnBu',figsize=(12,12),lw=0,linecolor='gray')
    mt = plt.setp(cg.ax_heatmap.yaxis.get_majorticklabels(), rotation=0, fontsize=9)
    mt = plt.setp(cg.ax_heatmap.xaxis.get_majorticklabels(), rotation=90)
    return cg 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:14,代码来源:plotting.py

示例7: cluster_map

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def cluster_map(data, names):
    """Cluster map of genes"""

    import seaborn as sns
    import pylab as plt
    data = data.ix[names]
    X = np.log(data).fillna(0)
    X = X.apply(lambda x: x-x.mean(), 1)
    cg = sns.clustermap(X,cmap='RdYlBu_r',figsize=(8,10),lw=.5,linecolor='gray')
    mt=plt.setp(cg.ax_heatmap.yaxis.get_majorticklabels(), rotation=0)
    mt=plt.setp(cg.ax_heatmap.xaxis.get_majorticklabels(), rotation=90)
    return cg 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:14,代码来源:de.py

示例8: make_plots

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def make_plots(dset, timemarks="0s,9d", ylim=None, columns=None,
            autoscale=False, events=None, interactive=False):
    pylab.ioff()
    names = []
    if type(events) is dataset.DataSet:
        events.normalize_time(dset.measurements[0][0])
    dset.normalize_time()
    unit = dset.unit

    for subset, start, end in dset.get_timeslices(timemarks):
        if len(subset) > 0:
            datacols, labels = subset.get_columns(columns)
            x_time = datacols[0]
            if len(x_time) < 100:
                mrk = "."
                ls = "-"
            else:
                mrk = ","
                ls = "None"
            for col, label, color in itertools.izip(datacols[1:], labels[1:], color_cycler):
                pylab.plot(x_time, col, color=color, label=label, ls=ls, marker=mrk)
            pylab.setp(pylab.gcf(), dpi=100, size_inches=(9,6))
            pylab.xlabel("Time (s)")
            pylab.ylabel(unit)

            if events is not None:
                ax = pylab.gca()
                for row in events:
                    ax.axvline(row[0], color="rgbymc"[int(row[1]) % 6])

            metadata = subset.metadata
            title = "%s-%s-%s-%ss-%ss" % (metadata.name,
                    metadata.timestamp.strftime("%m%d%H%M%S"),
                    "-".join(labels),
                    int(start),
                    int(end))
            pylab.title(title, fontsize="x-small")
            font = FontProperties(size="x-small")
            pylab.legend(prop=font)

            if not interactive:
                fname = "%s.%s" % (title, "png")
                pylab.savefig(fname, format="png")
                names.append(fname)
                pylab.cla()
        else:
            break
    return names


# Functions for interactive reporting from command line. 
开发者ID:kdart,项目名称:pycopia,代码行数:53,代码来源:dataplots.py

示例9: make_inset

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def make_inset(figure="current", width=1, height=1):
    """

    This guy makes the figure thick and small, like an inset.
    Currently assumes there is only one set of axes in the window!

    """

    # get the current figure if we're not supplied with one
    if figure == "current": figure = _pylab.gcf()

    # get the window
    w = figure.canvas.GetParent()

    # first set the size of the window
    w.SetSize([220,300])

    # we want thick axis lines
    figure.axes[0].get_frame().set_linewidth(3.0)

    # get the tick lines in one big list
    xticklines = figure.axes[0].get_xticklines()
    yticklines = figure.axes[0].get_yticklines()

    # set their marker edge width
    _pylab.setp(xticklines+yticklines, mew=2.0)

    # set what kind of tickline they are (outside axes)
    for l in xticklines: l.set_marker(_mpl.lines.TICKDOWN)
    for l in yticklines: l.set_marker(_mpl.lines.TICKLEFT)

    # get rid of the top and right ticks
    figure.axes[0].xaxis.tick_bottom()
    figure.axes[0].yaxis.tick_left()

    # we want bold fonts
    _pylab.xticks(fontsize=20, fontweight='bold', fontname='Arial')
    _pylab.yticks(fontsize=20, fontweight='bold', fontname='Arial')

    # we want to give the labels some breathing room (1% of the data range)
    figure.axes[0].xaxis.set_ticklabels([])
    figure.axes[0].yaxis.set_ticklabels([])


    # set the position/size of the axis in the window
    figure.axes[0].set_position([0.1,0.1,0.1+0.7*width,0.1+0.7*height])

    # set the axis labels to empty (so we can add them with a drawing program)
    figure.axes[0].set_title('')
    figure.axes[0].set_xlabel('')
    figure.axes[0].set_ylabel('')

    # set the position of the legend far away
    figure.axes[0].legend=None

    # zoom!
    auto_zoom(figure.axes[0], 0.07, 0.07) 
开发者ID:Spinmob,项目名称:spinmob,代码行数:59,代码来源:_pylab_tweaks.py

示例10: draw_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import setp [as 别名]
def draw_plot(self):
        """ Redraws the plot
        """
        # when xmin is on auto, it "follows" xmax to produce a 
        # sliding window effect. therefore, xmin is assigned after
        # xmax.
        #
        if self.xmax_control.is_auto():
            xmax = len(self.data) if len(self.data) > 50 else 50
        else:
            xmax = int(self.xmax_control.manual_value())
            
        if self.xmin_control.is_auto():            
            xmin = xmax - 50
        else:
            xmin = int(self.xmin_control.manual_value())

        # for ymin and ymax, find the minimal and maximal values
        # in the data set and add a mininal margin.
        # 
        # note that it's easy to change this scheme to the 
        # minimal/maximal value in the current display, and not
        # the whole data set.
        # 
        if self.ymin_control.is_auto():
            ymin = round(min(self.data), 0) - 1
        else:
            ymin = int(self.ymin_control.manual_value())
        
        if self.ymax_control.is_auto():
            ymax = round(max(self.data), 0) + 1
        else:
            ymax = int(self.ymax_control.manual_value())

        self.axes.set_xbound(lower=xmin, upper=xmax)
        self.axes.set_ybound(lower=ymin, upper=ymax)
        
        # anecdote: axes.grid assumes b=True if any other flag is
        # given even if b is set to False.
        # so just passing the flag into the first statement won't
        # work.
        #
        if self.cb_grid.IsChecked():
            self.axes.grid(True, color='gray')
        else:
            self.axes.grid(False)

        # Using setp here is convenient, because get_xticklabels
        # returns a list over which one needs to explicitly 
        # iterate, and setp already handles this.
        #  
        pylab.setp(self.axes.get_xticklabels(), 
            visible=self.cb_xlab.IsChecked())
        
        self.plot_data.set_xdata(np.arange(len(self.data)))
        self.plot_data.set_ydata(np.array(self.data))
        
        self.canvas.draw() 
开发者ID:eliben,项目名称:code-for-blog,代码行数:60,代码来源:wx_mpl_dynamic_graph.py


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