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


Python rcParams.update函数代码示例

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


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

示例1: run_demo

def run_demo(path, ext, seed):
    from matplotlib import rcParams
    import numpy.random
    from mplchaco import mpl2chaco
    mpldir = os.path.join(path, "mpl")
    chacodir = os.path.join(path, "chaco")
    mkdirp(mpldir)
    mkdirp(chacodir)

    # like IPython inline plot
    rcParams.update({
        'figure.figsize': (6.0, 4.0),
        'font.size': 10,
        'savefig.dpi': 72,
        'figure.subplot.bottom': 0.125,
    })
    numpy.random.seed(seed)

    imgfmt = "{{0}}.{0}".format(ext).format
    for func in demos:
        fig = func()
        cfig = mpl2chaco(fig)

        dpi = fig.get_dpi()
        width = fig.get_figwidth() * dpi
        height = fig.get_figheight() * dpi

        mplpath = imgfmt(os.path.join(mpldir, func.__name__))
        chacopath = imgfmt(os.path.join(chacodir, func.__name__))
        fig.savefig(mplpath)
        save_plot(cfig.plot, chacopath, width, height)
开发者ID:tkf,项目名称:mplchaco,代码行数:31,代码来源:demo.py

示例2: MicrOscilloscope1

def MicrOscilloscope1(SoundBoard, Rate, YLim, FreqBand, MicSens_VPa, FramesPerBuf=512, Rec=False):
    Params = {'backend': 'Qt5Agg'}
    from matplotlib import rcParams; rcParams.update(Params)
    import matplotlib.animation as animation
    from matplotlib import pyplot as plt
    
    SBInAmpF = Hdf5F.SoundCalibration(SBAmpFsFile, SoundBoard,
                                              'SBInAmpF')
    
    r = pyaudio.PyAudio()
    
    Plotting = r.open(format=pyaudio.paFloat32,
                         channels=1,
                         rate=Rate,
                         input=True,
                         output=False,
                         #input_device_index=18,
                         frames_per_buffer=FramesPerBuf)
                         #stream_callback=InCallBack)
    
    Fig = plt.figure()
    Ax = plt.axes(xlim=FreqBand, ylim=YLim)
    Plot, = Ax.plot([float('nan')]*(Rate//10), lw=1)
    
    def AnimInit():
        Data = array.array('f', [])
        Plot.set_ydata(Data)
        return Plot,
    
    def PltUp(n):
#        Data = array.array('f', Plotting.read(Rate//10))
        Data = array.array('f', Plotting.read(Rate//10, 
                                              exception_on_overflow=False))
        Data = [_ * SBInAmpF for _ in Data]
        HWindow = signal.hanning(len(Data)//(Rate/1000))
        F, PxxSp = signal.welch(Data, Rate, HWindow, nperseg=len(HWindow), noverlap=0, 
                                scaling='density')
        
        Start = np.where(F > FreqBand[0])[0][0]-1
        End = np.where(F > FreqBand[1])[0][0]-1
        BinSize = F[1] - F[0]
        RMS = sum(PxxSp[Start:End] * BinSize)**0.5
        dB = 20*(math.log(RMS/MicSens_VPa, 10)) + 94
        print(dB, max(PxxSp))
        
        Plot.set_xdata(F)
        Plot.set_ydata(PxxSp)
        return Plot,
    
    Anim = animation.FuncAnimation(Fig, PltUp, frames=FramesPerBuf, interval=16, 
                                   blit=False)
    
    if Rec:
        Writers = animation.writers['ffmpeg']
        Writer = Writers(fps=15, metadata=dict(artist='Me'))
        Anim.save('MicrOscilloscope.mp4', writer=Writer)
    
    plt.show()
        
    return(None)
开发者ID:malfatti,项目名称:SciScripts,代码行数:60,代码来源:ControlSoundBoard.py

示例3: valueOccurenceGraphInverse

def valueOccurenceGraphInverse(nameDict, height):
    valueOps = [nameDict[name].opAtHeight(height) for name in nameDict]
    values = [x.value for x in valueOps if x is not None]
    counter = collections.Counter(values)
    prevCount = 0
    maxValues = len(values)
    total = len(values)
    xData = []
    yData = []

    for value, count in reversed(counter.most_common()):
        if count > prevCount:
            xData.append(prevCount)
            yData.append(total/maxValues)
            for i in range(prevCount + 1, count):
                xData.append(i)
                yData.append(total/maxValues)
        total -= count
        prevCount = count
    xData.append(count)
    yData.append(total)
    
    ax = plt.subplot(111)
    plt.plot(xData, yData)
    ax.set_xlim([-300,20000])
    formatter = FuncFormatter(to_percent)
    plt.gca().yaxis.set_major_formatter(formatter)


    plt.xlabel(r"\textbf{Value occurs more than n times}")
    plt.ylabel(r"\textbf{Percent of total names}")
    rc('font', serif='Helvetica Neue') 
    rc('text', usetex='true') 
    rcParams.update({'font.size': 16})
    rcParams.update({'figure.autolayout': True})
开发者ID:Aranjedeath,项目名称:namecoin-analysis,代码行数:35,代码来源:nameHistory.py

示例4: imshow_wrapper

def imshow_wrapper(H, title=None, fname=None, size=(2.2, 2.2), adjust=0.):
    fig = plt.figure()
    ax = fig.add_subplot(111)
    font = {'family' : 'normal',
            'weight' : 'bold',
            'size'   : 8}
    matplotlib.rc('font', **font)
    rcParams.update({'figure.autolayout': True})
    
    plt.imshow(H, cmap=cm.Greys)
    plt.colorbar()
    plt.xlabel('column index')
    plt.ylabel('row index')
    if title == None:
        plt.title('Entries of H')
    else:
        plt.title(title)
    xticks = ax.xaxis.get_major_ticks()
    xticks[-1].label1.set_visible(False)
    yticks = ax.yaxis.get_major_ticks()
    yticks[-1].label1.set_visible(False)
    F = plt.gcf()
    F.subplots_adjust(left=adjust)
    plt.show()
    F.set_size_inches(size)
    if fname != None:
        fig.savefig(fname + '.eps')
开发者ID:appcoreopc,项目名称:mrnmf,代码行数:27,代码来源:NMF_algs.py

示例5: plotV

def plotV(Sall):
    params = {
        'axes.labelsize': 10,
        'font.size': 10,
        'legend.fontsize': 10,
        'xtick.labelsize': 10,
        'ytick.labelsize': 10,
        'text.usetex': False,
        'figure.figsize': [3.8, 3.8],
    }
    rcParams.update(params)
    for i in range(Sall.secNum):
        h1, = plot(Sall.S[i], Sall.V[i]*3.6, color="black", linewidth=1) #, label=u'速度曲线'
        h2, = plot(Sall.S[i], [Sall.secLimit[i]*3.6]*len(Sall.S[i]), color="black", linewidth=1, linestyle="--")
    
    ylim(0.0,100.0)
    xlim(12100, 13600)
    gca().invert_xaxis()
    xlabel('公里标(m)')
    ylabel('速度(m/s)')
    h1._label = "速度曲线"
    h2._label = "速度限制"
    legend(loc='upper right')
    savefig("S6.pdf", dpi=600)
    show()
开发者ID:Scicomath,项目名称:gmcm,代码行数:25,代码来源:plotScript.py

示例6: draw_bar

def draw_bar(means, density):
    from matplotlib import rcParams
    rcParams.update({'figure.autolayout': True})

    ind = np.arange(len(means))  # the x locations for the groups
    width = 0.35       # the width of the bars

    fig, ax = plt.subplots()
    rects = ax.bar(ind, means, width, color='g')

    # add some text for labels, title and axes ticks
    ax.set_ylabel('Milliseconds')
    ax.set_title('Average running time on %s networks' % density)
    ax.set_xticks(ind+width)
    ax.set_xticklabels(('Ford-Fulkerson', 'Edmonds-Karp', 'Capacity scaling', 'Generic push relabel', 'Relabel to front'),
                       rotation=40, ha='right', fontsize=10)

    def autolabel(rects):
        # attach some text labels
        for i, rect in enumerate(rects):
            height = rect.get_height()
            ax.text(rect.get_x()+rect.get_width()/2., height + 0.05, '%d' % means[i],
                    ha='center', va='bottom')

    autolabel(rects)

    plt.savefig(util.get_out_file('chart', '%s.png' % density))
开发者ID:JovanCe,项目名称:mfp,代码行数:27,代码来源:bar_chart.py

示例7: myScatter

def myScatter(lst,xtxt="",ytxt="",f="out.pdf"):
  import matplotlib
  import matplotlib.pyplot as plt
  from matplotlib.backends.backend_agg \
       import FigureCanvasAgg as FigureCanvas
  from matplotlib.figure import Figure
  import numpy
  from matplotlib import rcParams
  rcParams.update({'figure.autolayout': True})
  asnum  = numpy.array
  x,y    = asnum([z[0] for z in lst]), \
            asnum([z[1] for z in lst])
  fig    = Figure(figsize=(4,2))
  canvas = FigureCanvas(fig)
  ax     = fig.add_subplot(111)
  ax.set_xlabel(xtxt,fontsize=9)
  ax.set_ylabel(ytxt,fontsize=9)
  ax.grid(True,linestyle='-',color='0.75')
  ax.set_ylim((-2,102))
  cm = plt.cm.get_cmap('RdYlGn')
  plt.ylim(-5,100)
  ax.plot(x,y,marker='o', linestyle='--', color='r', label='Square')
  ax.tick_params(axis='both', which='major', labelsize=9)
  ax.tick_params(axis='both', which='minor', labelsize=9)
  print(f)
  canvas.print_figure(f,dpi=500)
开发者ID:ai-se,项目名称:leaner,代码行数:26,代码来源:learn.py

示例8: plot_TS

def plot_TS(temp, psal, depth, lon, lat, svec, tvec, density, title, m, figname):
    '''
    Create the T-S diagram
    '''
    logger = logging.getLogger(__name__)
    fig = plt.figure(figsize=(15, 15))
    rcParams.update({'font.size': 18})
    plt.scatter(psal, temp, s=5, c=depth, vmin=10., vmax=1000.,
               edgecolor='None', cmap=plt.cm.plasma)
    cbar = plt.colorbar(extend='max')
    plt.xlabel('Salinity', fontsize=18)
    plt.ylabel('Temperature\n($^{\circ}$C)', rotation=0, ha='right', fontsize=18)
    cont = plt.contour(svec, tvec, density, levels=np.arange(22., 32., 1.), 
                       colors='.65', linestyles='dashed', lineswidth=0.5)
    plt.clabel(cont,inline=True, fmt='%1.1f')
    plt.xlim(smin, smax)
    plt.ylim(tmin, tmax)
    cbar.set_label('Depth\n(m)', rotation=0, ha='left')
    plt.grid(color="0.6")

    # Add an inset showing the positions of the platform
    inset=plt.axes([0.135, 0.625, 0.3, 0.35])
    lon2plot, lat2plot = m(lon, lat)
    m.drawmapboundary(color='w')
    m.plot(lon2plot, lat2plot, 'ro', ms=2, markeredgecolor='r')
    #m.drawcoastlines(linewidth=0.25)
    m.drawlsmask(land_color='0.4', ocean_color='0.9', lakes=False)
    plt.title(title, fontsize=20)
    plt.savefig(figname, dpi=150)
    # plt.show()
    plt.close()
开发者ID:ctroupin,项目名称:CMEMS_INSTAC_Training,代码行数:31,代码来源:plot_TS_diagram_all.py

示例9: rcParams

    def rcParams(self):
        """
        Return rcParams dict for this theme.

        Notes
        -----
        Subclasses should not need to override this method method as long as
        self._rcParams is constructed properly.

        rcParams are used during plotting. Sometimes the same theme can be
        achieved by setting rcParams before plotting or a apply
        after plotting. The choice of how to implement it is is a matter of
        convenience in that case.

        There are certain things can only be themed after plotting. There
        may not be an rcParam to control the theme or the act of plotting
        may cause an entity to come into existence before it can be themed.

        """

        try:
            rcParams = deepcopy(self._rcParams)
        except NotImplementedError:
            # deepcopy raises an error for objects that are drived from or
            # composed of matplotlib.transform.TransformNode.
            # Not desirable, but probably requires upstream fix.
            # In particular, XKCD uses matplotlib.patheffects.withStrok
            rcParams = copy(self._rcParams)

        for th in self.themeables.values():
            rcParams.update(th.rcParams)
        return rcParams
开发者ID:jwhendy,项目名称:plotnine,代码行数:32,代码来源:theme.py

示例10: config_plot

    def config_plot(self, arg_list):
        """Configure global plot parameters"""
        import matplotlib
        from matplotlib import rcParams

        # set rcParams
        rcParams.update({
            'figure.dpi': 100.,
            'font.family': 'sans-serif',
            'font.size': 16.,
            'font.weight': 'book',
            'legend.loc': 'best',
            'lines.linewidth': 1.5,
            'text.usetex': 'true',
            'agg.path.chunksize': 10000,
        })

        # determine image dimensions (geometry)
        self.width = 1200
        self.height = 768
        if arg_list.geometry:
            try:
                self.width, self.height = map(float,
                                              arg_list.geometry.split('x', 1))
                self.height = max(self.height, 500)
            except (TypeError, ValueError) as e:
                e.args = ('Cannot parse --geometry as WxH, e.g. 1200x600',)
                raise

        self.dpi = rcParams['figure.dpi']
        self.xinch = self.width / self.dpi
        self.yinch = self.height / self.dpi
        rcParams['figure.figsize'] = (self.xinch, self.yinch)
        return
开发者ID:WanduiAlbert,项目名称:gwpy,代码行数:34,代码来源:cliproduct.py

示例11: setFigForm

def setFigForm():
    """set the rcparams to EmulateApJ columnwidth=245.26 pts """

    fig_width_pt = 245.26 * 2
    inches_per_pt = 1.0 / 72.27
    golden_mean = (math.sqrt(5.0) - 1.0) / 2.0
    fig_width = fig_width_pt * inches_per_pt
    fig_height = fig_width * golden_mean
    fig_size = [1.5 * fig_width, fig_height]

    params = {
        "backend": "ps",
        "axes.labelsize": 12,
        "text.fontsize": 12,
        "legend.fontsize": 7,
        "xtick.labelsize": 11,
        "ytick.labelsize": 11,
        "text.usetex": True,
        "font.family": "serif",
        "font.serif": "Times",
        "image.aspect": "auto",
        "figure.subplot.left": 0.1,
        "figure.subplot.bottom": 0.1,
        "figure.subplot.hspace": 0.25,
        "figure.figsize": fig_size,
    }

    rcParams.update(params)
开发者ID:OSSOS,项目名称:MOP,代码行数:28,代码来源:figures.py

示例12: make_boxplot_temperature

def make_boxplot_temperature(caObj, name, modis_lvl2=False):
    low_clouds = get_calipso_low_clouds(caObj)
    high_clouds = get_calipso_high_clouds(caObj)
    medium_clouds = get_calipso_medium_clouds(caObj)
    temp_c = caObj.calipso.all_arrays['layer_top_temperature'][:,0] +273.15 
    if modis_lvl2:
        temp_pps = caObj.modis.all_arrays['temperature']
    else:
        temp_pps = caObj.imager.all_arrays['ctth_temperature']  
    if modis_lvl2:
        height_pps = caObj.modis.all_arrays['height']
    else:
        height_pps = caObj.imager.all_arrays['ctth_height']

    thin = np.logical_and(caObj.calipso.all_arrays['feature_optical_depth_532_top_layer_5km']<0.30, 
                          caObj.calipso.all_arrays['feature_optical_depth_532_top_layer_5km']>0) 
    very_thin = np.logical_and(caObj.calipso.all_arrays['feature_optical_depth_532_top_layer_5km']<0.10, 
                          caObj.calipso.all_arrays['feature_optical_depth_532_top_layer_5km']>0) 
    thin_top = np.logical_and(caObj.calipso.all_arrays['number_layers_found']>1, thin)
    thin_1_lay = np.logical_and(caObj.calipso.all_arrays['number_layers_found']==1, thin)
    use = np.logical_and(temp_pps >100,
                         caObj.calipso.all_arrays['layer_top_altitude'][:,0]>=0)
    use = np.logical_and(height_pps <45000,use)
    low = np.logical_and(low_clouds,use)
    medium = np.logical_and(medium_clouds,use)
    high = np.logical_and(high_clouds,use)
    c_all = np.logical_or(high,np.logical_or(low,medium))
    high_very_thin = np.logical_and(high, very_thin)
    high_thin = np.logical_and(high, np.logical_and(~very_thin,thin))
    high_thick = np.logical_and(high, ~thin)
    #print "thin, thick high", np.sum(high_thin), np.sum(high_thick) 
    bias = temp_pps - temp_c
    abias = np.abs(bias)
    #abias[abias>2000]=2000
    print name.ljust(30, " "), "%3.1f"%(np.mean(abias[c_all])), "%3.1f"%(np.mean(abias[low])),"%3.1f"%(np.mean(abias[medium])),"%3.1f"%(np.mean(abias[high]))

    c_all = np.logical_or(np.logical_and(~very_thin,high),np.logical_or(low,medium))
    number_of = np.sum(c_all)
     
    #print name.ljust(30, " "), "%3.1f"%(np.sum(abias[c_all]<250)*100.0/number_of), "%3.1f"%(np.sum(abias[c_all]<500)*100.0/number_of),  "%3.1f"%(np.sum(abias[c_all]<1000)*100.0/number_of), "%3.1f"%(np.sum(abias[c_all]<1500)*100.0/number_of), "%3.1f"%(np.sum(abias[c_all]<2000)*100.0/number_of), "%3.1f"%(np.sum(abias[c_all]<3000)*100.0/number_of), "%3.1f"%(np.sum(abias[c_all]<4000)*100.0/number_of), "%3.1f"%(np.sum(abias[c_all]<5000)*100.0/number_of)
    from matplotlib import rcParams
    rcParams.update({'figure.autolayout': True})
    fig = plt.figure(figsize = (6,9))        
    ax = fig.add_subplot(111)
    plt.xticks(rotation=70)
    ax.fill_between(np.arange(0,8),-2.5,2.5, facecolor='green', alpha=0.6)
    ax.fill_between(np.arange(0,8),-5,5, facecolor='green', alpha=0.4)
    ax.fill_between(np.arange(0,8),-7.5,7.5, facecolor='green', alpha=0.2)
    ax.fill_between(np.arange(0,8),10,150, facecolor='red', alpha=0.2)
    ax.fill_between(np.arange(0,8),-20,-10, facecolor='red', alpha=0.2)
    for y_val in [-5,-4,-3,-2,-1,1,2,3,4,5]:
        plt.plot(np.arange(0,8), y_val*20 + 0*np.arange(0,8),':k', alpha=0.4)
    plt.plot(np.arange(0,8), 0 + 0*np.arange(0,8),':k', alpha=0.4)
    bplot = ax.boxplot([bias[low],bias[medium],bias[high],bias[high_thick],bias[high_thin],bias[high_very_thin]],whis=[5, 95],sym='',
                labels=["low","medium","high-all","high-thick\n od>0.4","high-thin \n 0.1<od<0.4","high-vthin\n od<0.1"],showmeans=True, patch_artist=True)
    ax.set_ylim(-20,100)
    for box in bplot['boxes']:
        box.set_facecolor('0.9')
    plt.title(name)
    plt.savefig(ADIR + "/PICTURES_FROM_PYTHON/CTTH_BOX/ctth_box_plot_temperature_%s_5_95_filt.png"%(name))
开发者ID:adybbroe,项目名称:atrain_match,代码行数:60,代码来源:plot_ctth_boxplots_mlvl2_temperature_pressure_height.py

示例13: __init__

	def __init__(self, parent):
		gui.MainFrame.__init__(self, parent)
		self.summaryFiles = []
		self.activeSummaryFiles = []
		self.testedAssemblers = []
		self.summaryParsers = []
		self.summaryLabels = []
		self.covData = {}
		self.covDataKeys = []
		self.covDataValues = []
		self.plotIndex = 0
		self.plotDir = ''
		self.newEntry = ''
		self.xAttribute = 'l'
		self.yAttribute = 'cN50'
		self.xUnits = 'bp'
		self.yUnits = 'bp'
		self.xScale = 'linear'
		self.yScale = 'linear'
		self.readFile = ''
		self.referencePickerName = ''
		self.contigPickerName = ''
		self.deBrujinAssemblers = ['abyss','ray','soap','velvet']
		self.deBrujin = ('ABySS assembler', 'SOAPdenovo2', 'Velvet', 'Ray assembler')
		self.styles = []
		rcParams.update({'figure.autolayout': True})
		self.atributes = ['l', 'cov', 'N', 'd', 'e', 'r', 'R', 'X', 'A', 'D']
		self.units = ['bp', 'coverage', 'num reads', '', '', '', '', '', '', '']
		self.detailsDict = {'cTotalNum':'(number of contigs)', 'cBiggerThen':'(num. of contigs bigger then s)',
							'cTotalLen' : '(total length of contigs)', 'cMaxLen' : '(maximum length of contigs)',
							'cMinLen' : '(minimum length of contigs)', 'cAvgLen' : '(average length of contigs)',
							'cMedLen' : '(median length of contigs)', 'cN50':'(N50 size of contigs)',
							'cN25':'(N25 size of contigs)', 'cN75':'(N75 size of contigs)', 'cN56':'(N56 size of contigs)',
							'sTotalNum':'(number of scaffolds)', 'sBiggerThen':'(num. of scaffolds bigger then s)',
							'sTotalLen' : '(total length of scaffolds)','sMaxSize' : '(maximum length of scaff.)',
							'sMinSize' : '(minimum length of scaff.','sAvgLen' : '(average length of scaff.)',
							'sMedSize' : '(median length of scaff.)', 'sN50':'(N50 size of scaffolds)',
							'sN25':'(N25 size of scaffolds)','sN56':'(N56 size of scaffolds)',
							'sN75':'(N75 size of scaffolds)','sEM':'(ratio between median and E-size[scaff.])',
							'sEN':'(ratio between n50 and E-size)','mAvgs':'(average length of scaff./average length of cont.)',
							'mN50s':'(N50[contigs]/N50[scaffolds])','mNums':'([number of contigs]/[number of scaffolds])',
							'mLens':'([total len. of cont.]/[total len. of scaff.])', 'mMaxs':'([max length of con.]/[max length of scaff.])',
							'totalRealTime':'(total execution time of all steps of the assembly process)',
							'totalCpuTime':'(total CPU time of all steps of the assembly process)',
							'totalRSS':'(peak memory usage [Resident Set Size])',
							'l':'(read length)',
							}
		self.atributes += ['totalRealTime', 'totalCpuTime', 'totalRSS', 'totalPSS', 'totalVmSize', 'cTotalNum', 'cBiggerThen', \
						   'cTotalLen', 'cMaxLen', 'cMinLen', 'cAvgLen', 'cMedLen', 'cESize', 'cN25', 'cN50', 'cN56', 'cN75', 'sTotalNum', \
						   'sMaxSize', 'sMinSize', 'sAvgSize', 'sMedSize', 'sCertainNum', 'sN25', 'sN50', 'sN56', 'sN75', 'sEM', 'sEN', 'sQual', 'mAvgs', 'mN50s', 'mNums', 'mLens', 'mMaxs','cReferenceCoverage']
		self.units += ['sec', 'sec', 'MB', 'MB', 'MB', '', '', \
					   'bp', 'bp', 'bp', 'bp', 'bp', '', 'bp', 'bp', 'bp', 'bp', '', \
					   'bp', 'bp', 'bp', 'bp', '', 'bp', 'bp', 'bp', 'bp', '', '', \
					   '', '', '', '', '', '',''];
		self.selectionMap = {0:'linear',1:'logarithmic'}
		self.checkListBoxInitialItems = {"abyss":0,"minimus":1,"sga":2,"pasqual":3,"soap":4,"celera":5,"velvet":6,"readjoiner":7, "ray":8}
		self.assemblerTypes = {}
		print "[AN:] Basic viewer 1.0 started at: ", time.strftime("%H:%M:%S")
		self.CreatePlot()
		self.createReadsPlot()
开发者ID:vzupanovic,项目名称:skripte,代码行数:60,代码来源:benchmarkGUI.py

示例14: temporal_analysis

def temporal_analysis():
    words = ["sorto", u"ryssä", "nais", "torppar", u"työttömy", "nykyi", "histor", "jumala", "kirkko", "jeesus", u"marx", u"sosialis", u"porwari", u"työ", u"työttömyy", u"työläi", u"työvä", u"kapitalis", u"taantu", u"taistel", u"toveri", u"vallankumou", "torppari", "agitaattori", u"köyhälistö", u"kärsi", "orja", "sort", "sosialidemokraatti", "lakko", "vapau", "voitto"]
    ts, soc_freqs, other_freqs = frequency_over_time(words)
    print 100000 * soc_freqs
    print 100000 * other_freqs
    from matplotlib import rcParams
    rcParams.update({'figure.autolayout': True})
    for i, word in enumerate(words):
        plt.figure(1)
        plt.clf()
        plt.plot(ts[:-1], soc_freqs[:,i], '-x')
        plt.plot(ts[:-1], other_freqs[:,i], '-o')
        max_y = max(np.max(soc_freqs[:,i]), np.max(other_freqs[:,i]))
        plt.ylim((0, max_y*1.05))
        plt.xlabel('Year')
        plt.ylabel('Frequency')
        plt.title(word)
        plt.legend(['Socialist', 'Others'], loc='best')
        plt.savefig('../plots/%s.png' % word)
        date_str = re.sub(" ", "T", str(dt.datetime.now()))[:-7]
        date_str = re.sub(":", "", date_str)
    pickle.dump((ts,soc_freqs,other_freqs,words), open('../plot_data/%s.pckl' % date_str, 'wb'))
    save_csv2(words, soc_freqs, ts, "socialist")
    save_csv2(words, other_freqs, ts, "others")
    save_csv(words, soc_freqs, "socialist")
    save_csv(words, other_freqs, "others")
开发者ID:dhh15,项目名称:fnewspapers,代码行数:26,代码来源:word_frequencies.py

示例15: pdf

def pdf(params={}, presentation='powerpoint'):

    if presentation == 'powerpoint':
        fontsize = 14
        figsize = (10,7.5)
        subplot_left = 0.15
        subplot_right = 0.85
        subplot_top = 0.8
        subplot_bottom = 0.15
        
    if presentation == 'paper':
        fontsize = 8
        figsize = (8,8)
        subplot_left = 0.2
        subplot_right = 0.8
        subplot_top = 0.8
        subplot_bottom = 0.2

    print 'Loading rcparams for saving to PDF'
    print 'NOTE: ipython plotting may not work as expected with these parameters loaded!'
    default_params = {'backend': 'Agg',
                      'ps.usedistiller': 'xpdf',
                      'ps.fonttype' : 3,
                      'pdf.fonttype' : 3,
                      'font.family' : 'sans-serif',
                      'font.serif' : 'Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman',
                      'font.sans-serif' : 'Helvetica, Avant Garde, Computer Modern Sans serif',
                      'font.cursive' : 'Zapf Chancery',
                      'font.monospace' : 'Courier, Computer Modern Typewriter',
                      'font.size' : fontsize,
                      'text.fontsize': fontsize,
                      'axes.labelsize': fontsize,
                      'axes.linewidth': 1.0,
                      'xtick.major.linewidth': 1,
                      'xtick.minor.linewidth': 1,
                      #'xtick.major.size': 6,
                      #'xtick.minor.size' : 3,
                      'xtick.labelsize': fontsize,
                      #'ytick.major.size': 6,
                      #'ytick.minor.size' : 3,
                      'ytick.labelsize': fontsize,
                      'figure.figsize': figsize,
                      'figure.dpi' : 72,
                      'figure.facecolor' : 'white',
                      'figure.edgecolor' : 'white',
                      'savefig.dpi' : 300,
                      'savefig.facecolor' : 'white',
                      'savefig.edgecolor' : 'white',
                      'figure.subplot.left': subplot_left,
                      'figure.subplot.right': subplot_right,
                      'figure.subplot.bottom': subplot_bottom,
                      'figure.subplot.top': subplot_top,
                      'figure.subplot.wspace': 0.2,
                      'figure.subplot.hspace': 0.2,
                      'lines.linewidth': 1.0,
                      'text.usetex': True, 
                      }
    for key, val in params.items():
        default_params[key] = val
    rcParams.update(default_params) 
开发者ID:alexlib,项目名称:FlyPlotLib,代码行数:60,代码来源:set_params.py


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