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


Python Figure.tight_layout方法代码示例

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


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

示例1: bargraph

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
def bargraph(request):
    p = request.GET    

    try:
        d = [(float(p['d10']), float(p['d11']), float(p['d12']), float(p['d13']), float(p['d14'])),
             (float(p['d20']), float(p['d21']), float(p['d22']), float(p['d23']), float(p['d24'])),
             (float(p['d30']), float(p['d31']), float(p['d32']), float(p['d33']), float(p['d34'])),
             (float(p['d40']), float(p['d41']), float(p['d42']), float(p['d43']), float(p['d44'])),
             (float(p['d50']), float(p['d51']), float(p['d52']), float(p['d53']), float(p['d54'])),
             (float(p['d60']), float(p['d61']), float(p['d62']), float(p['d63']), float(p['d64'])),
             (float(p['d70']), float(p['d71']), float(p['d72']), float(p['d73']), float(p['d74'])),
             (float(p['d80']), float(p['d81']), float(p['d82']), float(p['d83']), float(p['d84']))]
    except:
        return render(request,"bad.html", { 'type':'bargraph' })

    tickM = ["2. Culture for retreatment",
         "3. GeneXpert for HIV positive only", 
         "4. GeneXpert for smear positive only", 
         "5. GeneXpert for all",
         "6. GeneXpert for all, culture confirmed",
         "7. MODS/TLA",
         "8. Same-day smear microscopy",
         "9. Same-day GeneXpert"]

    colors = ["grey","blue","green","yellow","red"]

    ndata = zip(*d)

    loc = np.arange(len(ndata[0]))
    width = 0.15

    fig = Figure(facecolor='white')
    canvas = FigureCanvas(fig)

    ax = fig.add_subplot(111)

    rect = [ax.bar(loc+width*i, ndata[i], width, color=colors[i]) 
            for i in range(len(ndata))]

    ax.set_ylim(-50,100)
    ax.set_xlim(-width*4, len(loc) +(4*width))

    ax.set_xticks(loc + (2.5*width))

    ax.set_xticklabels(tickM, rotation='30', size='small', stretch='condensed',
                       ha='right' )

    ax.legend ((rect[0][0], rect[1][0], rect[2][0], rect[3][0], rect[4][0]),
                ("TBInc", "MDRInc", "TBMort", "Yr1Cost", "Yr5Cost"),loc='best')

    ax.set_title ("Graph Comparison")
    ax.axhline(color='black')

    ax.set_ylabel('percentage change from baseline')

    fig.tight_layout()

    response=HttpResponse(content_type='image/png')
    canvas.print_png(response,facecolor=fig.get_facecolor())
    return response
开发者ID:JJPennington,项目名称:FlexDx-TB-Web-Django,代码行数:62,代码来源:views.py

示例2: make_1d_overlay

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
def make_1d_overlay(in_file_name, out_dir, ext, subset, b_effs=[0.1, 0.2]):
    textsize = _text_size - 2
    b_eff_styles = _b_eff_styles

    taggers = {x:{} for x in b_effs}
    with h5py.File(in_file_name, 'r') as in_file:
        for b_eff in taggers:
            for tag in (subset or _default_overlay_1d):
                taggers[b_eff][tag] = get_c_vs_u_const_beff(
                    in_file, tag, b_eff=b_eff)

    fig = Figure(figsize=_fig_size)
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(1,1,1)
    for b_eff, linestyle in zip(b_effs, b_eff_styles):
        for tname, (vc, vu) in taggers[b_eff].items():
            label, color = leg_labels_colors.get(tname, (tname, 'k'))
            lab = '$1 / \epsilon_{{ b }} = $ {rej:.0f}, {tname}'.format(
                rej=1/b_eff, tname=label)
            ax.plot(vc, vu, label=lab, color=color, linewidth=_line_width,
                    linestyle=linestyle)
    ax.set_xlim(0.1, 0.5)
    legprops = {'size':textsize}
    leg = ax.legend(prop=legprops)
    leg.get_title().set_fontsize(textsize)

    setup_1d_ctag_legs(ax, textsize)

    fig.tight_layout(pad=0, h_pad=0, w_pad=0)
    if not isdir(out_dir):
        os.mkdir(out_dir)
    file_name = '{}/ctag-1d-brej-overlay{}'.format(
        out_dir, ext)
    canvas.print_figure(file_name, bbox_inches='tight')
开发者ID:dguest,项目名称:tagging-performance,代码行数:36,代码来源:ctaging.py

示例3: plotThreeWay

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
def plotThreeWay(hist, title, filename=None, x_axis_title=None, minimum=None, maximum=None, bins=101):  # the famous 3 way plot (enhanced)
    if minimum is None:
        minimum = 0
    elif minimum == 'minimum':
        minimum = np.ma.min(hist)
    if maximum == 'median' or maximum is None:
        median = np.ma.median(hist)
        maximum = median * 2  # round_to_multiple(median * 2, math.floor(math.log10(median * 2)))
    elif maximum == 'maximum':
        maximum = np.ma.max(hist)
        maximum = maximum  # round_to_multiple(maximum, math.floor(math.log10(maximum)))
    if maximum < 1 or hist.all() is np.ma.masked:
        maximum = 1

    x_axis_title = '' if x_axis_title is None else x_axis_title
    fig = Figure()
    FigureCanvas(fig)
    fig.patch.set_facecolor('white')
    ax1 = fig.add_subplot(311)
    create_2d_pixel_hist(fig, ax1, hist, title=title, x_axis_title="column", y_axis_title="row", z_min=minimum if minimum else 0, z_max=maximum)
    ax2 = fig.add_subplot(312)
    create_1d_hist(fig, ax2, hist, bins=bins, x_axis_title=x_axis_title, y_axis_title="#", x_min=minimum, x_max=maximum)
    ax3 = fig.add_subplot(313)
    create_pixel_scatter_plot(fig, ax3, hist, x_axis_title="channel=row + column*336", y_axis_title=x_axis_title, y_min=minimum, y_max=maximum)
    fig.tight_layout()
    if not filename:
        fig.show()
    elif isinstance(filename, PdfPages):
        filename.savefig(fig)
    else:
        fig.savefig(filename)
开发者ID:liuhb08,项目名称:pyBAR,代码行数:33,代码来源:plotting.py

示例4: __init__

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
    def __init__(self, histogramNumbers, histogramBins, title='', xlabel='', ylabel=''):
        self.histNum =  histogramNumbers
        self.histBins = histogramBins
        self.text_title = title
        self.text_xlabel = xlabel
        self.text_ylabel = ylabel
        
        # init figure
        fig = Figure(figsize=(5, 2.5))
        self.axes = fig.add_subplot(111)
        
        # We want the axes cleared every time plot() is called
        self.axes.hold(False)
        
        # plot data
        self.compute_initial_figure()

        # init canvas (figure -> canvas)
        FigureCanvas.__init__(self, fig)
        #self.setParent(parent)
        
        # setup
        fig.tight_layout()
        FigureCanvas.setSizePolicy(self,
                                   QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
开发者ID:vlukes,项目名称:lisa,代码行数:29,代码来源:histology_analyser_gui.py

示例5: PlotOverview

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
class PlotOverview(qtgui.QWidget):
    def __init__(self, db):
        self.db = db
        self.fig = Figure()
        self.canvas = FigureCanvas(self.fig)
        super().__init__()

        lay_v = qtgui.QVBoxLayout()
        self.setLayout(lay_v)

        self.year = qtgui.QComboBox()
        self.year.currentIndexChanged.connect(self.plot)

        lay_h = qtgui.QHBoxLayout()
        lay_h.addWidget(self.year)
        lay_h.addStretch(1)
        lay_v.addLayout(lay_h)
        lay_v.addWidget(self.canvas)

        self.update()

    def update(self):
        constraints = self.db.get_constraints()
        current_year = self.year.currentText()
        self.year.clear()
        years = [y for y in range(min(constraints['start_date']).year, datetime.datetime.now().year + 1)]
        self.year.addItems([str(y) for y in years])
        try:
            self.year.setCurrentIndex(years.index(current_year))
        except ValueError:
            self.year.setCurrentIndex(len(years) - 1)

    def plot(self):
        self.fig.clf()
        ax = self.fig.add_subplot(111)

        worked = np.zeros((12, 34)) + np.nan

        year = int(self.year.currentText())
        for month in range(12):
            for day in range(calendar.monthrange(year, month + 1)[1]):
                date = datetime.date(year, month + 1, day + 1)
                if date < datetime.datetime.now().date():
                    t = self.db.get_worktime(date).total_seconds() / 60.0 - self.db.get_desiredtime(date)
                    worked[month, day] = t
                    ax.text(day, month, re.sub('0(?=[.])', '', ('{:.1f}'.format(t / 60))), ha='center', va='center')

        worked[:, 32:] = np.nansum(worked[:, :31], axis=1, keepdims=True)

        for month in range(12):
            ax.text(32.5, month, re.sub('0(?=[.])', '', ('{:.1f}'.format(worked[month, -1] / 60))), ha='center', va='center')

        ax.imshow(worked, vmin=-12*60, vmax=12*60, interpolation='none', cmap='coolwarm')
        ax.set_xticks(np.arange(31))
        ax.set_yticks(np.arange(12))
        ax.set_xticklabels(1 + np.arange(31))
        ax.set_yticklabels(calendar.month_name[1:])

        self.fig.tight_layout()
        self.canvas.draw()
开发者ID:mbillingr,项目名称:timetracker,代码行数:62,代码来源:statisticsdialog.py

示例6: MplAxes

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
class MplAxes(object):
    def __init__(self, parent):
        self._parent = parent
        self._parent.resizeEvent = self.resize_graph
        self.create_axes()
        self.redraw_figure()

    def create_axes(self):
        self.figure = Figure(None, dpi=100)
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setParent(self._parent)

        axes_layout = QtGui.QVBoxLayout(self._parent)
        axes_layout.setContentsMargins(0, 0, 0, 0)
        axes_layout.setSpacing(0)
        axes_layout.setMargin(0)
        axes_layout.addWidget(self.canvas)
        self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                  QtGui.QSizePolicy.Expanding)
        self.canvas.updateGeometry()
        self.axes = self.figure.add_subplot(111)

    def resize_graph(self, event):
        new_size = event.size()
        self.figure.set_size_inches([new_size.width() / 100.0, new_size.height() / 100.0])
        self.redraw_figure()

    def redraw_figure(self):
        self.figure.tight_layout(None, 0.8, None, None)
        self.canvas.draw()
开发者ID:kif,项目名称:Py2DeX,代码行数:32,代码来源:XRS_MainView.py

示例7: make_Histogram

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
 def make_Histogram(self):
     self.read_table()
     functions.process(self.dispData, self.dicData)
     self.make_CorrFigs()
     self.make_TMSFig()
     on = self.dicData['hdf5_on']  # this one contains all the histogram axis
     res = self.dicData['res']  # this contains the calculation results
     fig1 = Figure(facecolor='white', edgecolor='white')
     ax1 = fig1.add_subplot(2, 2, 1)
     ax2 = fig1.add_subplot(2, 2, 2)
     ax3 = fig1.add_subplot(2, 2, 3)
     ax4 = fig1.add_subplot(2, 2, 4)
     ax1.imshow(res.IQmapM_avg[0], interpolation='nearest', origin='low',
                extent=[on.xII[0], on.xII[-1], on.yII[0], on.yII[-1]], aspect='auto')
     ax2.imshow(res.IQmapM_avg[1], interpolation='nearest', origin='low',
                extent=[on.xQQ[0], on.xQQ[-1], on.yQQ[0], on.yQQ[-1]], aspect='auto')
     ax3.imshow(res.IQmapM_avg[2], interpolation='nearest', origin='low',
                extent=[on.xIQ[0], on.xIQ[-1], on.yIQ[0], on.yIQ[-1]], aspect='auto')
     ax4.imshow(res.IQmapM_avg[3], interpolation='nearest', origin='low',
                extent=[on.xQI[0], on.xQI[-1], on.yQI[0], on.yQI[-1]], aspect='auto')
     fig1.tight_layout()
     ax1.set_title('IIc')
     ax2.set_title('QQc')
     ax3.set_title('IQc')
     ax4.set_title('QIc')
     self.update_page_1(fig1)  # send figure to the show_figure terminal
     self.read_table()
开发者ID:benschneider,项目名称:sideprojects1,代码行数:29,代码来源:start.py

示例8: draw

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
	def draw(self, isotherms=True, isochores=True, isentrops=True, qIsolines=True, fig = None):
		if (fig is None):
			fig = Figure(figsize=(16.0, 10.0), facecolor='white')
		self.fig = fig
		self.ax = self.fig.add_subplot(1,1,1)
		self.ax.set_xlabel('Enthalpy [kJ/kg]')
		self.ax.set_ylabel('Pressure [bar]')
		self.ax.set_title(self.fluidName, y=1.04)
		self.ax.grid(True, which = 'both')
		
		x_in, y_in = self.fig.get_size_inches()
		dpi = self.fig.get_dpi()
		self.x_pts = x_in * dpi
		self.y_pts = y_in * dpi
		
		self.ax.set_xlim(self.hMin / 1e3, self.hMax / 1e3)
		self.ax.set_ylim(self.pMin / 1e5, self.pMax / 1e5)
		
		if qIsolines:
			self.plotDome()
		if isochores:
			self.plotIsochores()
		if isotherms:
			self.plotIsotherms()
		if isentrops:
			self.plotIsentrops()
		
		self.ax.legend(loc='upper center',  bbox_to_anchor=(0.5, 1.05),  fontsize="small", ncol=4)
		fig.tight_layout()
		return fig
开发者ID:SysMo,项目名称:SmoWeb,代码行数:32,代码来源:StateDiagrams.py

示例9: plot_alpha_parameters

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
def plot_alpha_parameters(pdict, outinfo):
    from matplotlib.figure import Figure
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigCanvas
    pars = []
    parlist, div_idxs = _sort_alpha(pdict)
    # in some fits we don't include systematics, don't draw anything
    if not parlist:
        return
    xlab, xpos, ypos, yerr = _get_lab_x_y_err(parlist)
    fig = Figure(figsize=(8, 4))
    fig.subplots_adjust(bottom=0.2)
    canvas = FigCanvas(fig)
    ax = fig.add_subplot(1,1,1)
    ax.set_xlim(0, len(xlab))
    ax.set_ylim(-2.5, 2.5)
    ax.errorbar(
        xpos, ypos, yerr=yerr, **_eb_style)
    ax.axhline(0, **_hline_style)
    for hline in div_idxs:
        ax.axvline(hline, **_hline_style)
    ax.set_xticks(xpos)
    ax.set_xticklabels(xlab)
    ax.tick_params(labelsize=_txt_size)
    for lab in ax.get_xticklabels():
        lab.set_rotation(60 if len(xlab) < 10 else 90)

    outdir = outinfo['outdir']
    fig.tight_layout(pad=0.3, h_pad=0.3, w_pad=0.3)
    canvas.print_figure(
        join(outdir, 'alpha' + outinfo['ext']), bboxinches='tight')
开发者ID:dguest,项目名称:susy-analysis,代码行数:32,代码来源:fitpars.py

示例10: draw_timeline

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
    def draw_timeline(self):
        fig = Figure(figsize=(7, 3))
        canvas = FigureCanvas(fig)
        ax = fig.add_subplot(111, axisbg="white")

        xseries = range(len(TRADING_MINUTES))
        pct = lambda x, _: "{0:1.1f}%".format(100*x)
        xseries_show = xseries[::30]
        xlabels_show = TRADING_MINUTES[::30]

        ax.clear()
        ax.plot(xseries, self._portfolio_timeline, label="portfolio", linewidth=1.0, color="r")
        ax.plot(xseries, self._benchmark_timeline, label="benchmark", linewidth=1.0, color="b")

        ax.yaxis.set_major_formatter(FuncFormatter(pct))
        for item in ax.get_yticklabels():
            item.set_size(10)

        ax.set_xlim(0, 240)
        ax.set_xticks(xseries_show)
        ax.set_xticklabels(xlabels_show, fontsize=10)

        ax.grid(True)
        ax.legend(loc=2, prop={"size": 9})

        fig.tight_layout()
        fig.savefig(SNAPSHOT_IMG_FILE)
        logger.info("Snapshot image saved at ./static/temp/snapshot.jpg.")
开发者ID:ColdHumour,项目名称:PortfolioMonitor,代码行数:30,代码来源:snapshot.py

示例11: confusion_matrix_

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
def confusion_matrix_(y_test,
                      y_pred,
                      target_names,
                      normalize=False,
                      title='Confusion matrix',
                      cmap=plt.cm.Blues):
    cm = confusion_matrix(y_test, y_pred)
    if normalize:
        cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
    np.set_printoptions(precision=2)
    fig = Figure()
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(111)
    im = ax.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)
    fig.colorbar(im)
    tick_marks = np.arange(len(target_names))
    ax.set_xticks(tick_marks)
    ax.set_xticklabels(target_names, rotation=45)
    ax.set_yticks(tick_marks)
    ax.set_yticklabels(target_names)
    fig.tight_layout()
    ax.set_title(title)
    ax.set_ylabel('True label')
    ax.set_xlabel('Predicted label')
    return fig
开发者ID:dssg,项目名称:cincinnati,代码行数:27,代码来源:plots.py

示例12: end

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
 def end(self):
     num_frames = len(self.results)
     xmax, ymax = self._get_lims()
     prev = None
     for i in range(10000):
         try:
             os.remove('%s%04d.png' % (self.pref, i + 1))
         except:
             break  # No more
     for i in range(num_frames):
         fig = Figure(figsize=(16, 9))
         canvas = FigureCanvasAgg(fig)
         ax = fig.add_subplot(111, xlim=(-xmax, xmax), ylim=(-ymax, ymax))
         prev = _plot_2d(ax, self.results[i], prev)
         ax.text(0, -ymax, 'Generation: %03d' % (i * self.step),
                 ha='left', va='bottom', fontsize=16)
         fig.tight_layout()
         canvas.print_figure('%s%04d.png' % (self.pref, i + 1))
     try:
         os.remove('%s.mp4' % self.pref)
     except FileNotFoundError:
         pass  # OK, does not exist
     os.system('avconv -r 1 -f image2 -i %s%%04d.png %s.mp4 -vcodec libx264'
               % (self.pref, self.pref))
     for i in range(num_frames):
         os.remove('%s%04d.png' % (self.pref, i + 1))
     return '%s.mp4' % self.pref
开发者ID:tiagoantao,项目名称:genomics-notebooks,代码行数:29,代码来源:chart.py

示例13: __init__

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
 def __init__(self, parent, red_farred):
     super(GraphPanel, self).__init__(parent, -1)
     self.SetBackgroundColour((218,238,255))
     self.SetWindowStyle(wx.RAISED_BORDER)
     figure = Figure()
     figure.set_facecolor(color='#daeeff')
     sizer = wx.BoxSizer(wx.VERTICAL)
     self.axes = figure.add_subplot(111)
     self.x_data = range(340, 821)
     self.axes.plot(self.x_data, [0] * 481, label='Scan 0')
     self.axes.legend(loc=1)
     self.canvas = FigureCanvasWxAgg(self, -1, figure)
     figure.tight_layout(pad=2.0)
     sizer.Add(self.canvas, 1, wx.EXPAND | wx.ALL)
     sizer.AddSpacer(20)
     add_toolbar(sizer, self.canvas)
     self.SetSizer(sizer)
     self.canvas.draw()
     cid1 = self.canvas.mpl_connect('motion_notify_event', self.on_movement)
     cid2 = self.canvas.mpl_connect('button_press_event', self.on_press)
     cid3 = self.canvas.mpl_connect('scroll_event', self.on_scroll)
     self.integ_lines = []
     self.fractional_lines = []
     self.plot_unit = -1
     self.plot_mode = -1
     self.text = None
     self.x_label = X_LABEL
     self.red_farred = red_farred
开发者ID:gramsejr,项目名称:Spectrovision,代码行数:30,代码来源:GraphPanel.py

示例14: DevPlot

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
class DevPlot(Plot):

  def __init__(self,k1={'intel_snb' : ['intel_snb','intel_snb','intel_snb']},k2={'intel_snb':['LOAD_1D_ALL','INSTRUCTIONS_RETIRED','LOAD_OPS_ALL']},processes=1,**kwargs):
    self.k1 = k1
    self.k2 = k2
    super(DevPlot,self).__init__(processes=processes,**kwargs)

  def plot(self,jobid,job_data=None):
    self.setup(jobid,job_data=job_data)
    cpu_name = self.ts.pmc_type
    type_name=self.k1[cpu_name][0]
    events = self.k2[cpu_name]

    ts=self.ts

    n_events = len(events)
    self.fig = Figure(figsize=(8,n_events*2+3),dpi=110)

    do_rate = True
    scale = 1.0
    if type_name == 'mem': 
      do_rate = False
      scale=2.0**10
    if type_name == 'cpu':
      scale=ts.wayness*100.0

    for i in range(n_events):
      self.ax = self.fig.add_subplot(n_events,1,i+1)
      self.plot_lines(self.ax, [i], xscale=3600., yscale=scale, do_rate = do_rate)
      self.ax.set_ylabel(events[i],size='small')
    self.ax.set_xlabel("Time (hr)")
    self.fig.subplots_adjust(hspace=0.5)
    self.fig.tight_layout()

    self.output('devices')
开发者ID:jgentle,项目名称:tacc_stats,代码行数:37,代码来源:devplot.py

示例15: make_1d_plots

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import tight_layout [as 别名]
def make_1d_plots(in_file_name, out_dir, ext, b_eff=0.1, reject='U'):
    textsize=_text_size
    taggers = {}
    with h5py.File(in_file_name, 'r') as in_file:
        for tag in ['gaia', mv1uc_name, 'jfc', 'jfit']:
            taggers[tag] = get_c_vs_u_const_beff(
                in_file, tag, b_eff=b_eff, reject=reject)

    fig = Figure(figsize=_fig_size)
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(1,1,1)
    for tname, (vc, vu) in taggers.items():
        label, color = leg_labels_colors.get(tname, (tname, 'k'))
        ax.plot(vc, vu, label=label, color=color, linewidth=_line_width)
    leg = ax.legend(title='$b$-rejection = {}'.format(1/b_eff),
                    prop={'size':textsize})
    leg.get_title().set_fontsize(textsize)

    setup_1d_ctag_legs(ax, textsize, reject=reject)

    fig.tight_layout(pad=0, h_pad=0, w_pad=0)
    if not isdir(out_dir):
        os.mkdir(out_dir)
    file_name = '{}/{rej}Rej-vs-cEff-brej{}{}'.format(
        out_dir, int(1.0/b_eff), ext, rej=reject.lower())
    canvas.print_figure(file_name, bbox_inches='tight')
开发者ID:dguest,项目名称:tagging-performance,代码行数:28,代码来源:ctaging.py


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