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


Python pyplot.setp函数代码示例

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


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

示例1: graph

def graph(excel, dflist):
    fig, axes = plt.subplots(nrows=4, ncols=3, figsize=(16, 9), sharex=False, sharey=False)
    #fig.subplots_adjust(wspace=0, hspace=0)
    fig.subplots_adjust(hspace=0.5, left=0.5, right=0.9, bottom=0.01, top=0.95)
    fig.autofmt_xdate()
    plt.setp(axes, xticklabels=[], yticks=[])

    for i, j in enumerate(dflist):
        df = pd.read_excel('C:/Users/TokuharM/Desktop/Python_Scripts/%s' %excel, sheetname ='%s' % j, na_values=['NA'],parse_dates=['date'])
        df.sort_index(by = ["date"])

        x = df[["date"]]
        y = df[["errors"]]

        ax = fig.add_subplot(4,3,i+1)
        #ax = fig.add_subplot(i/3+1,i%3+1,1)
        ax.plot(x, y, "-o") #axに対してラベル幅などの調整を行う

        if len(x) > 0:
            days = mdates.DayLocator()
            daysFmt = mdates.DateFormatter('%m-%d')
            ax.xaxis.set_major_locator(days)
            ax.xaxis.set_major_formatter(daysFmt)
            ax.xaxis.set_ticks(pd.date_range(x.iloc[1,0], x.iloc[-1,0], freq='7d'))
            #ax.set_xlabel('Date')
            ax.set_ylabel('Errors')
            #ax.set_xticklabels('off')
            #ax.set_yticklabels('off')
            ax.grid()
            plt.xticks(rotation=30, fontsize='8')
            plt.yticks(range(0,400,30), fontsize='8')
            plt.axis('tight')
            ax.set_title(j, fontsize='10')
    plt.tight_layout(pad=1.0, w_pad=1.0, h_pad=1.0)
    plt.show()
开发者ID:minhouse,项目名称:python-dev,代码行数:35,代码来源:logsearch_v2.py

示例2: _analyze_class_distribution

def _analyze_class_distribution(csv_filepath,
                                max_data=1000,
                                bin_size=25):
    """Plot the distribution of training data over graphs."""
    symbol_id2index = generate_index(csv_filepath)
    index2symbol_id = {}
    for index, symbol_id in symbol_id2index.items():
        index2symbol_id[symbol_id] = index
    data, y = load_images(csv_filepath, symbol_id2index, one_hot=False)

    data = {}
    for el in y:
        if el in data:
            data[el] += 1
        else:
            data[el] = 1
    classes = data
    images = len(y)

    # Create plot
    print("Classes: %i" % len(classes))
    print("Images: %i" % images)

    class_counts = sorted([count for _, count in classes.items()])
    print("\tmin: %i" % min(class_counts))

    fig = plt.figure()
    ax1 = fig.add_subplot(111)
    # plt.title('HASY training data distribution')
    plt.xlabel('Amount of available testing images')
    plt.ylabel('Number of classes')

    # Where we want the ticks, in pixel locations
    ticks = [int(el) for el in list(np.linspace(0, 200, 21))]
    # What those pixel locations correspond to in data coordinates.
    # Also set the float format here
    ax1.set_xticks(ticks)
    labels = ax1.get_xticklabels()
    plt.setp(labels, rotation=30)

    min_examples = 0
    ax1.hist(class_counts, bins=range(min_examples, max_data + 1, bin_size))
    # plt.show()
    filename = '{}.pdf'.format('data-dist')
    plt.savefig(filename)
    logging.info("Plot has been saved as {}".format(filename))

    symbolid2latex = _get_symbolid2latex()

    top10 = sorted(classes.items(), key=lambda n: n[1], reverse=True)[:10]
    top10_data = 0
    for index, count in top10:
        print("\t%s:\t%i" % (symbolid2latex[index2symbol_id[index]], count))
        top10_data += count
    total_data = sum([count for index, count in classes.items()])
    print("Top-10 has %i training data (%0.2f%% of total)" %
          (top10_data, float(top10_data) * 100.0 / total_data))
    print("%i classes have more than %i data items." %
          (sum([1 for _, count in classes.items() if count > max_data]),
           max_data))
开发者ID:mehdidc,项目名称:data_tools,代码行数:60,代码来源:hasy_tools.py

示例3: barPlot

	def barPlot(self, datalist, threshold, figname):

		tally = self.geneCount(datalist)

		#Limit the items plotted to those over 1% of the read mass
		geneplot = defaultdict()
		for g, n in tally.iteritems():
			if n > int(sum(tally.values())*threshold):
				geneplot[g] = n

		#Get plotting values
		olist = OrderedDict(sorted(geneplot.items(),key=lambda t: t[0]))
		summe = sum(olist.values())
		freq = [float(x)/float(summe) for x in olist.values()]
		
		#Create plot
		fig = plt.figure()
		width = .35
		ind = np.arange(len(geneplot.keys()))
		plt.bar(ind, freq)
		plt.xticks(ind + width, geneplot.keys())
		locs, labels = plt.xticks() 
		plt.setp(labels, rotation=90)
		plt.show()

		fig.savefig(figname)
		print("Saved bar plot as: "+figname)
开发者ID:cnellington,项目名称:Antibody-Statistics,代码行数:27,代码来源:annotationstats.py

示例4: legend

    def legend(self, ax, handles, labels, **kwargs):
        '''Make a legend, following guidelines in USGS Illustration Standards, p. 14

        ax : matplotlib.pyplot axis object
        handles : list
            matplotlib.pyplot handles for each plot
        labels : list
            labels for each plot
        kwargs : dict
            keyword arguments to matplotlib.pyplot.legend()
        '''

        lgkwargs = {'title': 'EXPLANATION',
                    'fontsize': self.legend_headingsize,
                    'frameon': False,
                    'loc': 8,
                    'bbox_to_anchor': (0.5, -0.25)}
        lgkwargs.update(kwargs)

        mpl.rcParams['font.family'] = self.title_font


        lg = ax.legend(handles, labels, **lgkwargs)

        plt.setp(lg.get_title(), fontsize=self.legend_titlesize)
        #reset rcParams back to default
        mpl.rcParams['font.family'] = self.default_font
        return lg
开发者ID:aleaf,项目名称:Figures,代码行数:28,代码来源:report_figs.py

示例5: plot_glucose_stems

def plot_glucose_stems( ax, ts ):
  # visualize glucose using stems
  markers, stems, baselines = ax.stem( ts.time, ts.value,
           linefmt='b:' )
  plt.setp( markers, color='red', linewidth=.5,
            marker='o' )
  plt.setp( baselines, marker='None' ) 
开发者ID:bewest,项目名称:diabetes,代码行数:7,代码来源:make_series.py

示例6: demo_locatable_axes_hard

def demo_locatable_axes_hard(fig1):

    from mpl_toolkits.axes_grid1 import SubplotDivider, LocatableAxes, Size

    divider = SubplotDivider(fig1, 2, 2, 2, aspect=True)

    # axes for image
    ax = LocatableAxes(fig1, divider.get_position())

    # axes for colorbar
    ax_cb = LocatableAxes(fig1, divider.get_position())

    h = [Size.AxesX(ax), Size.Fixed(0.05), Size.Fixed(0.2)]  # main axes  # padding, 0.1 inch  # colorbar, 0.3 inch

    v = [Size.AxesY(ax)]

    divider.set_horizontal(h)
    divider.set_vertical(v)

    ax.set_axes_locator(divider.new_locator(nx=0, ny=0))
    ax_cb.set_axes_locator(divider.new_locator(nx=2, ny=0))

    fig1.add_axes(ax)
    fig1.add_axes(ax_cb)

    ax_cb.axis["left"].toggle(all=False)
    ax_cb.axis["right"].toggle(ticks=True)

    Z, extent = get_demo_image()

    im = ax.imshow(Z, extent=extent, interpolation="nearest")
    plt.colorbar(im, cax=ax_cb)
    plt.setp(ax_cb.get_yticklabels(), visible=False)
开发者ID:KevKeating,项目名称:matplotlib,代码行数:33,代码来源:demo_axes_divider.py

示例7: PlotScatter

def PlotScatter(x, y, delta, ax, showXTicks):
  if x.size < 1:
    return
  plt.plot(x,y,'.', color=c1, alpha=0.3)
  # set xticks
  if not showXTicks:
    plt.setp(ax.get_xticklabels(), visible=False) 
开发者ID:tunino91,项目名称:dpOptTrans,代码行数:7,代码来源:plotResults.py

示例8: do_plot

def do_plot(mds, plot, ymax, extra=None):
    fig = plt.figure()
    ax = fig.add_subplot(111)
    steps = mds.Steps.Steps
    values = mds.MDS.Values
    if ymax is None:
        ymax = np.max(values)
    Graph.timeSeries(ax, steps, values, 'b', label='MDS', Ave=True)
    plt.xlabel('time')
    plt.ylabel(r'$ops/sec$')
    if not mds.CPU is None:
        values = mds.CPU.Values
        (handles, labels) = Graph.percent(ax, steps, values, 'k',
                                          label='% CPU', Ave=True)
        if (not handles is None) and (not labels is None):
            plt.legend(handles, labels)
        else:
            print "mds.do_plot(): Warning - Plotting CPU utilization failed."
    else:
        plt.legend()
    plt.setp( ax.get_xticklabels(), rotation=30, horizontalalignment='right')
    start_time = steps[0]/(24.0*60.0*60.0) + mpl.dates.date2num(datetime.date(1970,1,1))
    plt.title("%s metadata operations for %s" %
              (mds.name,
               mpl.dates.num2date(start_time).strftime("%Y-%m-%d"))
              )
    if ymax is None:
        ymax = ymax
    ax.set_ybound(lower=0, upper=ymax)
    if plot is None:
        plt.show()
    else:
        plt.savefig(plot)
    plt.cla()
开发者ID:dani-lbnl,项目名称:lmt,代码行数:34,代码来源:mds.py

示例9: move_rightSlider

    def move_rightSlider(self):
        """ Re-setup left range line in figure.
        Triggered by a change in Qt Widget.  NO EVENT is required.
        """
        newx = self.ui.horizontalSlider_2.value()
        if newx >= self._leftSlideValue and newx != self._rightSlideValue:
            # Allowed value: move the value bar
            self._rightSlideValue = newx

            xlim = self.ui.mainplot.get_xlim()
            newx = xlim[0] + newx*(xlim[1] - xlim[0])*0.01
            leftx = [newx, newx]
            lefty = self.ui.mainplot.get_ylim()
            setp(self.rightslideline, xdata=leftx, ydata=lefty)

            self.ui.graphicsView.draw()

            # Change value
            self.ui.lineEdit_4.setText(str(newx))

        else:
            # Reset the value
            self.ui.horizontalSlider_2.setValue(self._rightSlideValue)

        return
开发者ID:rosswhitfield,项目名称:mantid,代码行数:25,代码来源:eventFilterGUI.py

示例10: plot_bar

def plot_bar(xlabels, Y):
    fig = plt.figure()
    ax = fig.add_subplot(111)
    
    ## the data
    N = len(Y)
    ## necessary variables
    ind = np.arange(N)                # the x locations for the groups
    width = 0.35                      # the width of the bars
    
    ## the bars
    rects1 = ax.bar(ind, Y, width,
                    color='red')
    
    ax.set_xlim(-width,len(ind)+width)
    ax.set_ylim(0, max(Y)*1.2)
    ax.set_ylabel('Counts')
    ax.set_title('Counts by country')
    #xTickMarks = ['Group'+str(i) for i in range(1,6)]
    ax.set_xticks(ind+width)
    xtickNames = ax.set_xticklabels(xlabels)
    plt.setp(xtickNames, rotation=40, fontsize=10, ha='right')
    
    ## add a legend
    #ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
    plt.tight_layout()
    plt.show()
开发者ID:ratulray,项目名称:IsraelPalestine,代码行数:27,代码来源:PlotBar.py

示例11: plot_tfidf_classfeats

def plot_tfidf_classfeats(dfs):
    fig = plt.figure(figsize=(12, 9), facecolor="w")
    for i, df in enumerate(dfs):

        ax = fig.add_subplot(len(dfs), 1, i+1)
        ax.spines["top"].set_visible(False)
        ax.spines["right"].set_visible(False)
        ax.set_frame_on(False)
        ax.get_xaxis().tick_bottom()
        ax.get_yaxis().tick_left()
        if i == len(dfs)-1:
            ax.set_xlabel("Feature name", labelpad=14, fontsize=14)
        ax.set_ylabel("Tf-Idf score", labelpad=16, fontsize=14)
        #if i == 0:
        ax.set_title("Mean Tf-Idf scores for label = " + str(df.label), fontsize=16)

        x = range(1, len(df)+1)
        ax.bar(x, df.tfidf, align='center', color='#3F5D7D')
        #ax.lines[0].set_visible(False)
        ax.set_xticks(x)
        ax.set_xlim([0,len(df)+1])
        xticks = ax.set_xticklabels(df.feature)
        #plt.ylim(0, len(df)+2)
        plt.setp(xticks, rotation='vertical') #, ha='right', va='top')
        plt.subplots_adjust(bottom=0.24, right=1, top=0.97, hspace=0.9)

    plt.show()
开发者ID:amitsingh2783,项目名称:kaggle,代码行数:27,代码来源:analyze.py

示例12: plot_all_trees

def plot_all_trees(p,title='str'):
#=====================================================
    """ Plots all rooted trees of order p.

        **Example**:

        Plot all trees of order 4::

            >>> from nodepy import rt
            >>> rt.plot_all_trees(4)  # doctest: +ELLIPSIS
            <matplotlib.figure.Figure object at ...>
    """
    import matplotlib.pyplot as pl
    forest=list_trees(p)
    nplots=len(forest)
    nrows=int(np.ceil(np.sqrt(float(nplots))))
    ncols=int(np.floor(np.sqrt(float(nplots))))
    if nrows*ncols<nplots: ncols=ncols+1
    for tree in forest:
        if title=='str': ttitle=tree
        else: ttitle=''
        tree.plot(nrows,ncols,forest.index(tree)+1,ttitle=ttitle)
    fig=pl.figure(1)
    pl.setp(fig,facecolor='white')
    return fig
开发者ID:alexfikl,项目名称:nodepy,代码行数:25,代码来源:rooted_trees.py

示例13: _drawScatterPlot

 def _drawScatterPlot(self,dates, values, plotidx, plotcount, title, refaxs):
     if( refaxs == None):
         logging.debug("initializing scatter plot")
         fig = plt.figure()
         #1 inch height for each author graph. So recalculate with height. Else y-scale get mixed.
         figHt = float(self.commitGraphHtPerAuthor*plotcount)
         fig.set_figheight(figHt)
         #since figureheight is in inches, set around maximum of 0.75 inches margin on top.
         topmarginfrac = min(0.15, 0.85/figHt)
         logging.debug("top/bottom margin fraction is %f" % topmarginfrac)
         fig.subplots_adjust(bottom=topmarginfrac, top=1.0-topmarginfrac, left=0.05, right=0.95)
     else:
         fig = refaxs.figure
         
     axs = fig.add_subplot(plotcount, 1, plotidx,sharex=refaxs,sharey=refaxs)
     axs.grid(True)
     axs.plot_date(dates, values, marker='.', xdate=True, ydate=False)
     axs.autoscale_view()
     
     #Pass None as 'handles' since I want to display just the titles
     axs.set_title(title, fontsize='small',fontstyle='italic')
     
     self._setXAxisDateFormatter(axs)        
     plt.setp( axs.get_xmajorticklabels(), visible=False)
     plt.setp( axs.get_xminorticklabels(), visible=False)
                 
     return(axs)
开发者ID:YESLTD,项目名称:svnplot,代码行数:27,代码来源:svnplotmatplotlib.py

示例14: plotSTAGE

def plotSTAGE(show=False):
    fig, stage = plt.subplots(1)
    title="Stage for PT's in Nu'uuli Stream"
    #### PT1 stage N1
    stage.plot_date(PT1['stage'].index,PT1['stage'],marker='None',ls='-',color='r',label='N1')
    print 'Lowest PT1 stage: '+'%.1f'%PT1['stage'].min()
    #### PT2 stage N2
    stage.plot_date(PT2['stage'].index,PT2['stage'],marker='None',ls='-',color='y',label='N2')

    ## show storm intervals?
    showstormintervals(stage,shade_color='g',show=True)
    
    #### Format X axis and Primary Y axis
    stage.set_title(title)
    stage.set_ylabel('Stage height in cm')
    stage.set_ylim(0,145)
    stage.legend(loc=2)
    #### Add Precip data from Timu1
    AddTimu1(fig,stage,Precip['Timu-Nuuuli1-15'])
    AddTimu1(fig,stage,Precip['Timu-Nuuuli2-15'],LineColor='g')
    
    plt.setp(stage.get_xticklabels(),rotation='vertical',fontsize=9)
    plt.subplots_adjust(left=0.1,right=0.83,top=0.93,bottom=0.15)
    #### Legend
    plt.legend(loc=1)
    fig.canvas.manager.set_window_title('Figure 1: '+title) 
    stage.grid(True)
    show_plot(show)
    return
开发者ID:gregmc31,项目名称:Fagaalu-Sediment-Flux,代码行数:29,代码来源:SedimentLoading-NUUULI.py

示例15: trendPicture

def trendPicture(rt,comment):
     
    colorList = ['b','g','r','c','m','y','k']
 
    threadList = []
    for i in range(len(rt)):
	threadList.append(i)
   
    dataList1 = [int(x) for x in rt]
    dataList2 = [int(x) for x in comment]
   
    string = str(len(dataList1)) + u'条微博趋势图'
    plt.title(string)

    
    lines = []

    titles = []

   
    line1 = plt.plot(threadList, dataList1)
    plt.setp(line1, color=colorList[0], linewidth=2.0)
    titles.append(u'转发')
    lines.append(line1)

   
    line2 = plt.plot(threadList, dataList2)
    plt.setp(line2, color=colorList[1], linewidth=2.0)
    titles.append(u'评论')
    lines.append(line2)

    plt.legend(lines, titles)
    plt.show()
开发者ID:shch,项目名称:weibo,代码行数:33,代码来源:photo.py


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