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


Python pylab.close方法代码示例

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


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

示例1: generate_png_chess_dp_vertex

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def generate_png_chess_dp_vertex(self):
    """Produces pictures of the dominant product vertex a chessboard convention"""
    import matplotlib.pylab as plt
    plt.ioff()
    dab2v = self.get_dp_vertex_doubly_sparse()
    for i, ab in enumerate(dab2v): 
        fname = "chess-v-{:06d}.png".format(i)
        print('Matrix No.#{}, Size: {}, Type: {}'.format(i+1, ab.shape, type(ab)), fname)
        if type(ab) != 'numpy.ndarray': ab = ab.toarray()
        fig = plt.figure()
        ax = fig.add_subplot(1,1,1)
        ax.set_aspect('equal')
        plt.imshow(ab, interpolation='nearest', cmap=plt.cm.ocean)
        plt.colorbar()
        plt.savefig(fname)
        plt.close(fig) 
开发者ID:pyscf,项目名称:pyscf,代码行数:18,代码来源:prod_basis.py

示例2: export_figure

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def export_figure(path_fig, fig):
    """ export the figure and close it afterwords

    :param str path_fig: path to the new figure image
    :param fig: object

    >>> path_fig = './sample_figure.jpg'
    >>> export_figure(path_fig, plt.figure())
    >>> os.remove(path_fig)
    """
    assert os.path.isdir(os.path.dirname(path_fig)), \
        'missing folder "%s"' % os.path.dirname(path_fig)
    fig.subplots_adjust(left=0., right=1., top=1., bottom=0.)
    logging.debug('exporting Figure: %s', path_fig)
    fig.savefig(path_fig)
    plt.close(fig) 
开发者ID:Borda,项目名称:BIRL,代码行数:18,代码来源:drawing.py

示例3: visualize_voxel_spectral

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def visualize_voxel_spectral(points, vis_size=128):
  """Function to visualize voxel (spectral)."""
  points = np.rint(points)
  points = np.swapaxes(points, 0, 2)
  fig = p.figure(figsize=(1, 1), dpi=vis_size)
  verts, faces = measure.marching_cubes_classic(points, 0, spacing=(0.1, 0.1, 0.1))
  ax = fig.add_subplot(111, projection='3d')
  ax.plot_trisurf(
      verts[:, 0], verts[:, 1], faces, verts[:, 2], cmap='Spectral_r', lw=0.1)
  ax.set_axis_off()
  fig.tight_layout(pad=0)
  fig.canvas.draw()
  data = np.fromstring(
      fig.canvas.tostring_rgb(), dtype=np.uint8, sep='').reshape(
          vis_size, vis_size, 3)
  p.close('all')
  return data 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:19,代码来源:utils.py

示例4: plot_alignment_to_numpy

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def plot_alignment_to_numpy(alignment, info=None):
    fig, ax = plt.subplots(figsize=(6, 4))
    im = ax.imshow(alignment, aspect='auto', origin='lower',
                   interpolation='none')
    fig.colorbar(im, ax=ax)
    xlabel = 'Decoder timestep'
    if info is not None:
        xlabel += '\n\n' + info
    plt.xlabel(xlabel)
    plt.ylabel('Encoder timestep')
    plt.tight_layout()

    fig.canvas.draw()
    data = save_figure_to_numpy(fig)
    plt.close()
    return data 
开发者ID:jxzhanggg,项目名称:nonparaSeq2seqVC_code,代码行数:18,代码来源:plotting_utils.py

示例5: plot_alignment

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def plot_alignment(alignments, text, _id, global_step, path):
    num_alignment = len(alignments)
    fig = plt.figure(figsize=(12, 16))
    for i, alignment in enumerate(alignments):
        ax = fig.add_subplot(num_alignment, 1, i + 1)
        im = ax.imshow(
            alignment,
            aspect='auto',
            origin='lower',
            interpolation='none')
        fig.colorbar(im, ax=ax)
        xlabel = 'Decoder timestep'
        ax.set_xlabel(xlabel)
        ax.set_ylabel('Encoder timestep')
        ax.set_title("layer {}".format(i + 1))
    fig.subplots_adjust(wspace=0.4, hspace=0.6)
    fig.suptitle(f"record ID: {_id}\nglobal step: {global_step}\ninput text: {str(text)}")
    fig.savefig(path, format='png')
    plt.close() 
开发者ID:nii-yamagishilab,项目名称:tacotron2,代码行数:21,代码来源:metrics.py

示例6: plotModelInNewFigure

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def plotModelInNewFigure(jobpath, hmodel, args):
  figHandle = pylab.figure()
  if args.doPlotData:
    Data = loadData(jobpath)
    plotData(Data)

  if hmodel.getObsModelName().count('ZMGauss') and hmodel.obsModel.D > 2:
    bnpy.viz.GaussViz.plotCovMatFromHModel(hmodel)
  elif hmodel.getObsModelName().count('Gauss'):
    bnpy.viz.GaussViz.plotGauss2DFromHModel(hmodel)
  elif args.dataName.lower().count('bars') > 0:
    pylab.close(figHandle)
    if args.doPlotTruth:
      Data = loadData(jobpath)
    else:
      Data = None
    bnpy.viz.BarsViz.plotBarsFromHModel(hmodel, Data=Data, 
                                        sortBySize=args.doSort, doShowNow=False)
  else:
    raise NotImplementedError('Unrecognized data/obsmodel combo') 
开发者ID:daeilkim,项目名称:refinery,代码行数:22,代码来源:PlotComps.py

示例7: visualize_voxel_spectral

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def visualize_voxel_spectral(points, vis_size=128):
  """Function to visualize voxel (spectral)."""
  points = np.rint(points)
  points = np.swapaxes(points, 0, 2)
  fig = p.figure(figsize=(1, 1), dpi=vis_size)
  verts, faces = measure.marching_cubes(points, 0, spacing=(0.1, 0.1, 0.1))
  ax = fig.add_subplot(111, projection='3d')
  ax.plot_trisurf(
      verts[:, 0], verts[:, 1], faces, verts[:, 2], cmap='Spectral_r', lw=0.1)
  ax.set_axis_off()
  fig.tight_layout(pad=0)
  fig.canvas.draw()
  data = np.fromstring(
      fig.canvas.tostring_rgb(), dtype=np.uint8, sep='').reshape(
          vis_size, vis_size, 3)
  p.close('all')
  return data 
开发者ID:loicmarie,项目名称:hands-detection,代码行数:19,代码来源:utils.py

示例8: plot_gate_outputs_to_numpy

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def plot_gate_outputs_to_numpy(gate_targets, gate_outputs):
    fig, ax = plt.subplots(figsize=(12, 3))
    ax.scatter(
        range(len(gate_targets)), gate_targets, alpha=0.5, color='green', marker='+', s=1, label='target',
    )
    ax.scatter(
        range(len(gate_outputs)), gate_outputs, alpha=0.5, color='red', marker='.', s=1, label='predicted',
    )

    plt.xlabel("Frames (Green target, Red predicted)")
    plt.ylabel("Gate State")
    plt.tight_layout()

    fig.canvas.draw()
    data = save_figure_to_numpy(fig)
    plt.close()
    return data 
开发者ID:NVIDIA,项目名称:NeMo,代码行数:19,代码来源:helpers.py

示例9: plot_true_and_augmented_data

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def plot_true_and_augmented_data(sample,noised_sample,label,n_examples):
    output_dir = os.path.split(FLAGS.output)[0]
    # Save augmented data
    plt.clf()
    fig, ax = plt.subplots(3,1)
    for t in range(noised_sample.shape[1]):
        ax[t].plot(noised_sample[:,t])
        ax[t].set_xlabel('time (samples)')
        ax[t].set_ylabel('amplitude')
    ax[0].set_title('window {:03d}, cluster_id: {}'.format(n_examples,label))
    plt.savefig(os.path.join(output_dir, "augmented_data",
                            'augmented_{:03d}.pdf'.format(n_examples)))
    plt.close()

    # Save true data
    plt.clf()
    fig, ax = plt.subplots(3,1)
    for t in range(sample.shape[1]):
        ax[t].plot(sample[:,t])
        ax[t].set_xlabel('time (samples)')
        ax[t].set_ylabel('amplitude')
    ax[0].set_title('window {:03d}, cluster_id: {}'.format(n_examples,label))
    plt.savefig(os.path.join(output_dir, "true_data",
                            'true__{:03d}.pdf'.format(n_examples)))
    plt.close() 
开发者ID:tperol,项目名称:ConvNetQuake,代码行数:27,代码来源:data_augmentation.py

示例10: _plot_to_string

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def _plot_to_string():
    try:
        from StringIO import StringIO
        make_bytes = lambda x: x.buf
    except ImportError:
        from io import BytesIO as StringIO
        make_bytes = lambda x: x.getbuffer()
    try:
        from urllib import quote
    except:
        from urllib.parse import quote
    import base64
    import matplotlib.pylab as plt
    imgdata = StringIO()
    plt.savefig(imgdata)
    plt.close()
    imgdata.seek(0) 
    image = base64.encodestring(make_bytes(imgdata))
    return str(quote(image)) 
开发者ID:jahuth,项目名称:convis,代码行数:21,代码来源:variable_describe.py

示例11: plot_losses

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def plot_losses(losses_d, losses_g, filename):
    losses_d = np.array(losses_d)
    fig, axes = plt.subplots(3, 2, figsize=(8, 8))
    axes = axes.flatten()
    axes[0].plot(losses_d[:, 0])
    axes[1].plot(losses_d[:, 1])
    axes[2].plot(losses_d[:, 2])
    axes[3].plot(losses_d[:, 3])
    axes[4].plot(losses_g)
    axes[0].set_title("losses_d")
    axes[1].set_title("losses_d_real")
    axes[2].set_title("losses_d_fake")
    axes[3].set_title("losses_d_gp")
    axes[4].set_title("losses_g")
    plt.tight_layout()
    plt.savefig(filename)
    plt.close() 
开发者ID:PacktPublishing,项目名称:Hands-On-Generative-Adversarial-Networks-with-Keras,代码行数:19,代码来源:resnet_wgan_gp_cifar10_train.py

示例12: append_website

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def append_website(self, filename, content,
                       replace_from='X?!do not replace anything!?X',
                       keep_at='</BODY>',):
        """append content to an existing website: replace content starting
        at line containing `replace_from` until line containin `keep_at`;
        by default, all content following `replace_from` is
        replaced
        """
        # read existing code
        existing_html = open(filename, 'r').readlines()

        # insert content into existing html
        outf = open(filename, 'w')
        delete = False
        for line in existing_html:
            if replace_from in line:
                delete = True
                continue
            if keep_at in line:
                outf.writelines(content)
                delete = False
            if delete:
                continue
            outf.writelines(line)
        outf.close() 
开发者ID:mommermi,项目名称:photometrypipeline,代码行数:27,代码来源:diagnostics.py

示例13: calibrate_division_model_test

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def calibrate_division_model_test():
    img = rgb2gray(plt.imread('test/kamera2.png'))
    y0 = np.array(img.shape)[::-1][np.newaxis].T / 2.
    z_n = np.linalg.norm(np.array(img.shape) / 2.)
    points = pilab_annotate_load('test/kamera2_lines.xml')
    points_per_line = 5
    num_lines = points.shape[0] / points_per_line
    lines_coords = np.array([points[i * points_per_line:i * points_per_line + points_per_line] for i in xrange(num_lines)])
    c = camera.calibrate_division_model(lines_coords, y0, z_n)

    import matplotlib.cm as cm
    plt.figure()
    plt.imshow(img, cmap=cm.gray)
    for line in xrange(num_lines):
        x = lines_coords[line, :, 0]
        plt.plot(x, lines_coords[line, :, 1], 'g')
        mc = camera.fit_line(lines_coords[line].T)
        plt.plot(x, mc[0] * x + mc[1], 'y')
        xy = c.undistort(lines_coords[line].T)
        plt.plot(xy[0, :], xy[1, :], 'r')
    plt.show()
    plt.close() 
开发者ID:smidm,项目名称:camera.py,代码行数:24,代码来源:camera_test.py

示例14: _setup_callbacks

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def _setup_callbacks(self):
    """Default callbacks for the UI."""

    # Pressing escape should stop the UI
    def _onkeypress(event):
      if event.key == 'escape':
        # Stop UI
        logging.info('Pressed escape, stopping UI.')
        plt.close(self._fig)
        sys.exit()

    self._fig.canvas.mpl_connect('key_release_event', _onkeypress)

    # Disable default keyboard shortcuts
    for key in ('keymap.fullscreen', 'keymap.home', 'keymap.back',
                'keymap.forward', 'keymap.pan', 'keymap.zoom', 'keymap.save',
                'keymap.quit', 'keymap.grid', 'keymap.yscale', 'keymap.xscale',
                'keymap.all_axes'):
      plt.rcParams[key] = ''

    # Disable logging of some matplotlib events
    log.getLogger('matplotlib').setLevel('WARNING') 
开发者ID:deepmind,项目名称:spriteworld,代码行数:24,代码来源:demo_ui.py

示例15: generate_png_spy_dp_vertex

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import close [as 别名]
def generate_png_spy_dp_vertex(self):
    """Produces pictures of the dominant product vertex in a common black-and-white way"""
    import matplotlib.pyplot as plt
    plt.ioff()
    dab2v = self.get_dp_vertex_doubly_sparse()
    for i,ab2v in enumerate(dab2v): 
      plt.spy(ab2v.toarray())
      fname = "spy-v-{:06d}.png".format(i)
      print(fname)
      plt.savefig(fname, bbox_inches='tight')
      plt.close()
    return 0 
开发者ID:pyscf,项目名称:pyscf,代码行数:14,代码来源:prod_basis.py


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