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


Python pylab.figure方法代码示例

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


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

示例1: generate_png_chess_dp_vertex

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [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: error_bar_plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def error_bar_plot(experiment_data, results, title="", ylabel=""):

    true_effect = experiment_data.true_effects.mean()
    estimators = list(results.keys())

    x = list(estimators)
    y = [results[estimator].ate for estimator in estimators]

    cis = [
        np.array(results[estimator].ci) - results[estimator].ate
        if results[estimator].ci is not None
        else [0, 0]
        for estimator in estimators
    ]
    err = [[abs(ci[0]) for ci in cis], [abs(ci[1]) for ci in cis]]

    plt.figure(figsize=(12, 5))
    (_, caps, _) = plt.errorbar(x, y, yerr=err, fmt="o", markersize=8, capsize=5)
    for cap in caps:
        cap.set_markeredgewidth(2)
    plt.plot(x, [true_effect] * len(x), label="True Effect")
    plt.legend(fontsize=12, loc="lower right")
    plt.ylabel(ylabel)
    plt.title(title) 
开发者ID:zykls,项目名称:whynot,代码行数:26,代码来源:mediator_utils.py

示例3: plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plot(self, words, num_points=None):
        if not num_points:
            num_points = len(words)

        embeddings = self.get_words_embeddings(words)
        tsne = TSNE(perplexity=30, n_components=2, init='pca', n_iter=5000)
        two_d_embeddings = tsne.fit_transform(embeddings[:num_points, :])

        assert two_d_embeddings.shape[0] >= len(words), 'More labels than embeddings'
        pylab.figure(figsize=(15, 15))  # in inches
        for i, label in enumerate(words[:num_points]):
            x, y = two_d_embeddings[i, :]
            pylab.scatter(x, y)
            pylab.annotate(label, xy=(x, y), xytext=(5, 2), textcoords='offset points',
                           ha='right', va='bottom')
        pylab.show() 
开发者ID:mouradmourafiq,项目名称:philo2vec,代码行数:18,代码来源:models.py

示例4: figure_plotting_space

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def figure_plotting_space():
    """
    defines the plotting space
    """
  
    fig = plt.figure(figsize=(10,10))
    bar_height = 0.04
    mini_gap = 0.03
    gap = 0.05
    graph_height = 0.24

    axH = fig.add_axes([0.1,gap+3*graph_height+2.5*mini_gap,0.87,bar_height])
    axS = fig.add_axes([0.1,gap+2*graph_height+2*mini_gap,0.87,graph_height])
    axV = fig.add_axes([0.1,gap+graph_height+mini_gap,0.87,graph_height])
    
    return fig, axH, axS, axV 
开发者ID:samsammurphy,项目名称:ee-atmcorr-timeseries,代码行数:18,代码来源:plots.py

示例5: plot_clustering

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None):
    pylab.figure(num=None, figsize=(8, 6))
    if km:
        pylab.scatter(x, y, s=50, c=km.predict(list(zip(x, y))))
    else:
        pylab.scatter(x, y, s=50)

    pylab.title(title)
    pylab.xlabel("Occurrence word 1")
    pylab.ylabel("Occurrence word 2")

    pylab.autoscale(tight=True)
    pylab.ylim(ymin=0, ymax=1)
    pylab.xlim(xmin=0, xmax=1)
    pylab.grid(True, linestyle='-', color='0.75')

    return pylab 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:19,代码来源:plot_kmeans_example.py

示例6: plot_entropy

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plot_entropy():
    pylab.clf()
    pylab.figure(num=None, figsize=(5, 4))

    title = "Entropy $H(X)$"
    pylab.title(title)
    pylab.xlabel("$P(X=$coin will show heads up$)$")
    pylab.ylabel("$H(X)$")

    pylab.xlim(xmin=0, xmax=1.1)
    x = np.arange(0.001, 1, 0.001)
    y = -x * np.log2(x) - (1 - x) * np.log2(1 - x)
    pylab.plot(x, y)
    # pylab.xticks([w*7*24 for w in [0,1,2,3,4]], ['week %i'%(w+1) for w in
    # [0,1,2,3,4]])

    pylab.autoscale(tight=True)
    pylab.grid(True)

    filename = "entropy_demo.png"
    pylab.savefig(os.path.join(CHART_DIR, filename), bbox_inches="tight") 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:23,代码来源:demo_mi.py

示例7: plot_roc

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plot_roc(auc_score, name, tpr, fpr, label=None):
    pylab.clf()
    pylab.figure(num=None, figsize=(5, 4))
    pylab.grid(True)
    pylab.plot([0, 1], [0, 1], 'k--')
    pylab.plot(fpr, tpr)
    pylab.fill_between(fpr, tpr, alpha=0.5)
    pylab.xlim([0.0, 1.0])
    pylab.ylim([0.0, 1.0])
    pylab.xlabel('False Positive Rate')
    pylab.ylabel('True Positive Rate')
    pylab.title('ROC curve (AUC = %0.2f) / %s' %
                (auc_score, label), verticalalignment="bottom")
    pylab.legend(loc="lower right")
    filename = name.replace(" ", "_")
    pylab.savefig(
        os.path.join(CHART_DIR, "roc_" + filename + ".png"), bbox_inches="tight") 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:19,代码来源:utils.py

示例8: create_figure

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def create_figure(im_size, figsize_max=MAX_FIGURE_SIZE):
    """ create an empty figure of image size maximise maximal size

    :param tuple(int,int) im_size:
    :param float figsize_max:
    :return:

    >>> fig, ax = create_figure((100, 150))
    >>> isinstance(fig, plt.Figure)
    True
    """
    assert len(im_size) >= 2, 'not valid image size - %r' % im_size
    size = np.array(im_size[:2])
    fig_size = size[::-1] / float(size.max()) * figsize_max
    fig, ax = plt.subplots(figsize=fig_size)
    return fig, ax 
开发者ID:Borda,项目名称:BIRL,代码行数:18,代码来源:drawing.py

示例9: export_figure

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [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

示例10: plot_total_dos

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plot_total_dos(self, **kwargs):
        """
        Plots the total DOS

        Args:
            **kwargs: Variables for matplotlib.pylab.plot customization (linewidth, linestyle, etc.)

        Returns:
            matplotlib.pylab.plot
        """
        try:
            import matplotlib.pylab as plt
        except ImportError:
            import matplotlib.pyplot as plt
        fig = plt.figure(1, figsize=(6, 4))
        ax1 = fig.add_subplot(111)
        ax1.set_xlabel("E (eV)", fontsize=14)
        ax1.set_ylabel("DOS", fontsize=14)
        plt.fill_between(self.energies, self.t_dos, **kwargs)
        return plt 
开发者ID:pyiron,项目名称:pyiron,代码行数:22,代码来源:dos.py

示例11: __init__

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def __init__(self, rect, wtype, *args, **kwargs):
        """
        Creates a matplotlib.widgets widget
        :param rect: The rectangle of the position [left, bottom, width, height] in relative figure coordinates
        :param wtype: A type from matplotlib.widgets, eg. Button, Slider, TextBox, RadioButtons
        :param args: Positional arguments passed to the widget
        :param kwargs: Keyword arguments passed to the widget and events used for the widget
                       eg. if wtype is Slider, on_changed=f can be used as keyword argument

        """
        self.ax = plt.axes(rect)
        events = {}
        for k in list(kwargs.keys()):
            if k.startswith('on_'):
                events[k] = kwargs.pop(k)
        self.object = wtype(self.ax, *args, **kwargs)
        for k in events:
            if hasattr(self.object, k):
                getattr(self.object, k)(events[k]) 
开发者ID:thouska,项目名称:spotpy,代码行数:21,代码来源:mpl.py

示例12: visualize_voxel_spectral

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [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

示例13: plot_pr

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plot_pr(auc_score, precision, recall, label=None, figure_path=None):
    """绘制R/P曲线"""
    try:
        from matplotlib import pylab
        pylab.figure(num=None, figsize=(6, 5))
        pylab.xlim([0.0, 1.0])
        pylab.ylim([0.0, 1.0])
        pylab.xlabel('Recall')
        pylab.ylabel('Precision')
        pylab.title('P/R (AUC=%0.2f) / %s' % (auc_score, label))
        pylab.fill_between(recall, precision, alpha=0.5)
        pylab.grid(True, linestyle='-', color='0.75')
        pylab.plot(recall, precision, lw=1)
        pylab.savefig(figure_path)
    except Exception as e:
        print("save image error with matplotlib")
        pass 
开发者ID:shibing624,项目名称:text-classifier,代码行数:19,代码来源:evaluate.py

示例14: plot_pr_curve

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plot_pr_curve(pr_curve_dml, pr_curve_base, title):
    """
      Function that plots the PR-curve.

      Args:
        pr_curve: the values of precision for each recall value
        title: the title of the plot
    """
    plt.figure(figsize=(16, 9))
    plt.plot(np.arange(0.0, 1.05, 0.05),
             pr_curve_base, color='r', marker='o', linewidth=3, markersize=10)
    plt.plot(np.arange(0.0, 1.05, 0.05),
             pr_curve_dml, color='b', marker='o', linewidth=3, markersize=10)
    plt.grid(True, linestyle='dotted')
    plt.xlabel('Recall', color='k', fontsize=27)
    plt.ylabel('Precision', color='k', fontsize=27)
    plt.yticks(color='k', fontsize=20)
    plt.xticks(color='k', fontsize=20)
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.0])
    plt.title(title, color='k', fontsize=27)
    plt.tight_layout()
    plt.show() 
开发者ID:MKLab-ITI,项目名称:ndvr-dml,代码行数:25,代码来源:utils.py

示例15: plotKChart

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import figure [as 别名]
def plotKChart(self, misClassDict, saveFigPath):
        kList = []
        misRateList = []
        for k, misClassNum in misClassDict.iteritems():
            kList.append(k)
            misRateList.append(1.0 - 1.0/k*misClassNum)

        fig = plt.figure(saveFigPath)
        plt.plot(kList, misRateList, 'r--')
        plt.title(saveFigPath)
        plt.xlabel('k Num.')
        plt.ylabel('Misclassified Rate')
        plt.legend(saveFigPath)
        plt.grid(True)
        plt.savefig(saveFigPath)
        plt.show()

################################### PART3 TEST ########################################
# 例子 
开发者ID:ysh329,项目名称:statistical-learning-methods-note,代码行数:21,代码来源:kNN.py


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