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


Python pylab.axes方法代码示例

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


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

示例1: plot_confusion_matrix

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axes [as 别名]
def plot_confusion_matrix(cm, genre_list, name, title):
    pylab.clf()
    pylab.matshow(cm, fignum=False, cmap='Blues', vmin=0, vmax=1.0)
    ax = pylab.axes()
    ax.set_xticks(range(len(genre_list)))
    ax.set_xticklabels(genre_list)
    ax.xaxis.set_ticks_position("bottom")
    ax.set_yticks(range(len(genre_list)))
    ax.set_yticklabels(genre_list)
    pylab.title(title)
    pylab.colorbar()
    pylab.grid(False)
    pylab.show()
    pylab.xlabel('Predicted class')
    pylab.ylabel('True class')
    pylab.grid(False)
    pylab.savefig(
        os.path.join(CHART_DIR, "confusion_matrix_%s.png" % name), bbox_inches="tight") 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:20,代码来源:utils.py

示例2: __init__

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

示例3: save_images

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axes [as 别名]
def save_images(self, X, imgfile, density=False):
        ax = plt.axes()
        x = X[:, 0]
        y = X[:, 1]
        if density:
            xy = np.vstack([x,y])
            z = scipy.stats.gaussian_kde(xy)(xy)
            ax.scatter(x, y, c=z, marker='o', edgecolor='')
        else:
            ax.scatter(x, y, marker='o', c=range(x.shape[0]),
                        cmap=plt.cm.coolwarm)

        if self.collection is not None:
            self.collection.set_transform(ax.transData)
            ax.add_collection(self.collection)


        ax.text(x[0], y[0], str('start'), transform=ax.transAxes)
        ax.axis([-0.2, 1.2, -0.2, 1.2])
        fig = plt.gcf()

        plt.savefig(imgfile)
        plt.close() 
开发者ID:rdevon,项目名称:cortex_old,代码行数:25,代码来源:euclidean.py

示例4: image2

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axes [as 别名]
def image2(vals, vmin=None, vmax=None, outFile=None,
           imageWidth=None, imageHeight=None, upOrDown='upper',
           cmap=M.cm.jet, makeFigure=False, **options
          ):
    M.clf()
    M.axes([0, 0, 1, 1])
    if vmin == 'auto': vmin = None
    if vmax == 'auto': vmax = None
    if imageWidth is not None: makeFigure = True
    if cmap is None or cmap == '': cmap = M.cm.jet
    if isinstance(cmap, types.StringType) and cmap != '':
        try:
            cmap = eval('M.cm.' + cmap)
        except:
            cmap = M.cm.jet

    if makeFigure:
        dpi = float(options['dpi'])
        width = float(imageWidth) / dpi
        height = float(imageHeight) / dpi
        f = M.figure(figsize=(width,height)).add_axes([0.1,0.1,0.8,0.8], frameon=True)

    if vmin is not None or vmax is not None: 
        if vmin is None:
            vmin = min(min(vals))
        else:
            vmin = float(vmin)
        if vmax is None:
            vmax = max(max(vals))
        else:
            vmax = float(vmax)
        vrange = vmax - vmin
        levels = N.arange(vmin, vmax, vrange/30.)
    else:
        levels = 30

    M.contourf(vals, levels, cmap=cmap, origin=upOrDown)
    evalKeywordCmds(options)
    if outFile: M.savefig(outFile, **validCmdOptions(options, 'savefig')) 
开发者ID:apache,项目名称:incubator-sdap-nexus,代码行数:41,代码来源:plotlib.py

示例5: plotBarsFromHModel

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axes [as 别名]
def plotBarsFromHModel(hmodel, Data=None, doShowNow=True, figH=None,
                       compsToHighlight=None, sortBySize=False,
                       width=12, height=3, Ktop=None):
    if Data is None:
        width = width/2
    if figH is None:
      figH = pylab.figure(figsize=(width,height))
    else:
      pylab.axes(figH)
    K = hmodel.allocModel.K
    VocabSize = hmodel.obsModel.comp[0].lamvec.size
    learned_tw = np.zeros( (K, VocabSize) )
    for k in xrange(K):
        lamvec = hmodel.obsModel.comp[k].lamvec 
        learned_tw[k,:] = lamvec / lamvec.sum()
    if sortBySize:
        sortIDs = np.argsort(hmodel.allocModel.Ebeta[:-1])[::-1]
        sortIDs = sortIDs[:Ktop]
        learned_tw = learned_tw[sortIDs] 
    if Data is not None and hasattr(Data, "true_tw"):
        # Plot the true parameters and learned parameters
        pylab.subplot(121)
        pylab.imshow(Data.true_tw, **imshowArgs)
        pylab.colorbar()
        pylab.title('True Topic x Word')
        pylab.subplot(122)
        pylab.imshow(learned_tw,  **imshowArgs)
        pylab.title('Learned Topic x Word')
    else:
        # Plot just the learned parameters
        aspectR = learned_tw.shape[1]/learned_tw.shape[0]
        while imshowArgs['vmax'] > 2 * np.percentile(learned_tw, 97):
          imshowArgs['vmax'] /= 5
        pylab.imshow(learned_tw, aspect=aspectR, **imshowArgs)

    if compsToHighlight is not None:
        ks = np.asarray(compsToHighlight)
        if ks.ndim == 0:
          ks = np.asarray([ks])
        pylab.yticks( ks, ['**** %d' % (k) for k in ks])
    if doShowNow and figH is None:
      pylab.show() 
开发者ID:daeilkim,项目名称:refinery,代码行数:44,代码来源:BarsViz.py


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