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


Python pylab.axis方法代码示例

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


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

示例1: plot_confusion_matrix

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def plot_confusion_matrix(y_true, y_pred, size=None, normalize=False):
    """plot_confusion_matrix."""
    cm = confusion_matrix(y_true, y_pred)
    fmt = "%d"
    if normalize:
        cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
        fmt = "%.2f"
    xticklabels = list(sorted(set(y_pred)))
    yticklabels = list(sorted(set(y_true)))
    if size is not None:
        plt.figure(figsize=(size, size))
    heatmap(cm, xlabel='Predicted label', ylabel='True label',
            xticklabels=xticklabels, yticklabels=yticklabels,
            cmap=plt.cm.Blues, fmt=fmt)
    if normalize:
        plt.title("Confusion matrix (norm.)")
    else:
        plt.title("Confusion matrix")
    plt.gca().invert_yaxis() 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:21,代码来源:__init__.py

示例2: plot_roc_curve

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def plot_roc_curve(y_true, y_score, size=None):
    """plot_roc_curve."""
    false_positive_rate, true_positive_rate, thresholds = roc_curve(
        y_true, y_score)
    if size is not None:
        plt.figure(figsize=(size, size))
        plt.axis('equal')
    plt.plot(false_positive_rate, true_positive_rate, lw=2, color='navy')
    plt.plot([0, 1], [0, 1], color='gray', lw=1, linestyle='--')
    plt.xlabel('False positive rate')
    plt.ylabel('True positive rate')
    plt.ylim([-0.05, 1.05])
    plt.xlim([-0.05, 1.05])
    plt.grid()
    plt.title('Receiver operating characteristic AUC={0:0.2f}'.format(
        roc_auc_score(y_true, y_score))) 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:18,代码来源:__init__.py

示例3: _cut_windows_vertically

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def _cut_windows_vertically(self, door_top, roof_top, sky_sig, win_strip):
        win_sig = np.percentile(win_strip, 85, axis=1)
        win_sig[sky_sig > 0.5] = 0
        if win_sig.max() > 0:
            win_sig /= win_sig.max()
        win_sig[:roof_top] = 0
        win_sig[door_top:] = 0
        runs, starts, values = run_length_encode(win_sig > 0.5)
        win_heights = runs[values]
        win_tops = starts[values]
        if len(win_heights) > 0:
            win_bottom = win_tops[-1] + win_heights[-1]
            win_top = win_tops[0]
            win_vertical_spacing = np.diff(win_tops).mean() if len(win_tops) > 1 else 0
        else:
            win_bottom = win_top = win_vertical_spacing = -1

        self.top = int(win_top)
        self.bottom = int(win_bottom)
        self.vertical_spacing = int(win_vertical_spacing)
        self.vertical_scores = make_list(win_sig)
        self.heights = np.array(win_heights)
        self.tops = np.array(win_tops) 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:25,代码来源:megafacade.py

示例4: ransac_guess_color

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def ransac_guess_color(colors, n_iter=50, std=2):
    colors = rgb2lab(colors)
    colors = colors.reshape(-1, 3)
    masked = colors[:, 0] < 0.1
    colors = colors[~masked]
    assert len(colors) > 0, "Must have at least one color"

    best_mu = np.array([0, 0, 0])
    best_n = 0
    for k in range(n_iter):
        subset = colors[np.random.choice(np.arange(len(colors)), 1)]

        mu = subset.mean(0)
        #inliers = (((colors - mu) ** 2 / std) < 1).all(1)
        inliers = ((np.sqrt(np.sum((colors - mu)**2, axis=1))  / std) < 1)

        mu = colors[inliers].mean(0)
        n = len(colors[inliers])
        if n > best_n:
            best_n = n
            best_mu = mu
    #import ipdb; ipdb.set_trace()
    best_mu = np.squeeze(lab2rgb(np.array([[best_mu]])))
    return best_mu 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:26,代码来源:megafacade.py

示例5: plot_rectified

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def plot_rectified(self):
        import pylab
        pylab.title('rectified')
        pylab.imshow(self.rectified)

        for line in self.vlines:
            p0, p1 = line
            p0 = self.inv_transform(p0)
            p1 = self.inv_transform(p1)
            pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='green')

        for line in self.hlines:
            p0, p1 = line
            p0 = self.inv_transform(p0)
            p1 = self.inv_transform(p1)
            pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='red')

        pylab.axis('image');
        pylab.grid(c='yellow', lw=1)
        pylab.plt.yticks(np.arange(0, self.l, 100.0));
        pylab.xlim(0, self.w)
        pylab.ylim(self.l, 0) 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:24,代码来源:rectify.py

示例6: plot_original

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def plot_original(self):
        import pylab
        pylab.title('original')
        pylab.imshow(self.data)

        for line in self.lines:
            p0, p1 = line
            pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='blue', alpha=0.3)

        for line in self.vlines:
            p0, p1 = line
            pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='green')

        for line in self.hlines:
            p0, p1 = line
            pylab.plot((p0[0], p1[0]), (p0[1], p1[1]), c='red')

        pylab.axis('image');
        pylab.grid(c='yellow', lw=1)
        pylab.plt.yticks(np.arange(0, self.l, 100.0));
        pylab.xlim(0, self.w)
        pylab.ylim(self.l, 0) 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:24,代码来源:rectify.py

示例7: plot_iris_knn

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def plot_iris_knn():
    iris = datasets.load_iris()
    X = iris.data[:, :2]  # we only take the first two features. We could
                        # avoid this ugly slicing by using a two-dim dataset
    y = iris.target

    knn = neighbors.KNeighborsClassifier(n_neighbors=3)
    knn.fit(X, y)

    x_min, x_max = X[:, 0].min() - .1, X[:, 0].max() + .1
    y_min, y_max = X[:, 1].min() - .1, X[:, 1].max() + .1
    xx, yy = np.meshgrid(np.linspace(x_min, x_max, 100),
                         np.linspace(y_min, y_max, 100))
    Z = knn.predict(np.c_[xx.ravel(), yy.ravel()])

    # Put the result into a color plot
    Z = Z.reshape(xx.shape)
    pl.figure()
    pl.pcolormesh(xx, yy, Z, cmap=cmap_light)

    # Plot also the training points
    pl.scatter(X[:, 0], X[:, 1], c=y, cmap=cmap_bold)
    pl.xlabel('sepal length (cm)')
    pl.ylabel('sepal width (cm)')
    pl.axis('tight') 
开发者ID:jakevdp,项目名称:sklearn_pydata2015,代码行数:27,代码来源:helpers.py

示例8: __init__

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def __init__(self, norder = 2):
		"""Initializes the class when returning an instance. Pass it the polynomial order. It will 
set up two figure windows, one for the graph the other for the coefficent interface. It will then initialize 
the coefficients to zero and plot the (not so interesting) polynomial."""
		
		self.order = norder
		
		self.c = M.zeros(self.order,'f')
		self.ax = [None]*(self.order-1)#M.zeros(self.order-1,'i') #Coefficent axes
		
		self.ffig = M.figure() #The first figure window has the plot
		self.replotf()
		
		self.cfig = M.figure() #The second figure window has the 
		row = M.ceil(M.sqrt(self.order-1))
		for n in xrange(self.order-1):
			self.ax[n] = M.subplot(row, row, n+1)
			M.setp(self.ax[n],'label', n)
			M.plot([0],[0],'.')
			M.axis([-1, 1, -1, 1]);
			
		self.replotc()
		M.connect('button_press_event', self.click_event) 
开发者ID:ActiveState,项目名称:code,代码行数:25,代码来源:recipe-576501.py

示例9: click_event

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def click_event(self, event):
		"""Whenever a click occurs on the coefficent axes we modify the coefficents and update the 
plot"""
		
		if event.xdata is None:#we clicked outside the axis
			return

		idx = M.getp(event.inaxes,'label')
		
		print idx, event.xdata, event.ydata
				
		self.c[idx] = event.xdata
		self.c[idx+1] = event.ydata

		self.replotf()
		self.replotc() 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-576501.py

示例10: transform_to_2d

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def transform_to_2d(data, max_axis):
    """
    Projects 3d data cube along one axis using maximum intensity with
    preservation of the signs. Adapted from nilearn.
    """
    import numpy as np

    # get the shape of the array we are projecting to
    new_shape = list(data.shape)
    del new_shape[max_axis]

    # generate a 3D indexing array that points to max abs value in the
    # current projection
    a1, a2 = np.indices(new_shape)
    inds = [a1, a2]
    inds.insert(max_axis, np.abs(data).argmax(axis=max_axis))

    # take the values where the absolute value of the projection
    # is the highest
    maximum_intensity_data = data[inds]

    return np.rot90(maximum_intensity_data) 
开发者ID:nipreps,项目名称:niworkflows,代码行数:24,代码来源:utils.py

示例11: padRightDownCorner

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def padRightDownCorner(img, stride, padValue):
    h = img.shape[0]
    w = img.shape[1]

    pad = 4 * [None]
    pad[0] = 0 # up
    pad[1] = 0 # left
    pad[2] = 0 if (h%stride==0) else stride - (h % stride) # down
    pad[3] = 0 if (w%stride==0) else stride - (w % stride) # right

    img_padded = img
    pad_up = np.tile(img_padded[0:1,:,:]*0 + padValue, (pad[0], 1, 1))
    img_padded = np.concatenate((pad_up, img_padded), axis=0)
    pad_left = np.tile(img_padded[:,0:1,:]*0 + padValue, (1, pad[1], 1))
    img_padded = np.concatenate((pad_left, img_padded), axis=1)
    pad_down = np.tile(img_padded[-2:-1,:,:]*0 + padValue, (pad[2], 1, 1))
    img_padded = np.concatenate((img_padded, pad_down), axis=0)
    pad_right = np.tile(img_padded[:,-2:-1,:]*0 + padValue, (1, pad[3], 1))
    img_padded = np.concatenate((img_padded, pad_right), axis=1)

    return img_padded, pad 
开发者ID:eddieyi,项目名称:caffe2-pose-estimation,代码行数:23,代码来源:utils.py

示例12: draw_adjacency_graph

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def draw_adjacency_graph(adjacency_matrix,
                         node_color=None,
                         size=10,
                         layout='graphviz',
                         prog='neato',
                         node_size=80,
                         colormap='autumn'):
    """draw_adjacency_graph."""
    graph = nx.from_scipy_sparse_matrix(adjacency_matrix)

    plt.figure(figsize=(size, size))
    plt.grid(False)
    plt.axis('off')

    if layout == 'graphviz':
        pos = nx.graphviz_layout(graph, prog=prog)
    else:
        pos = nx.spring_layout(graph)

    if len(node_color) == 0:
        node_color = 'gray'
    nx.draw_networkx_nodes(graph, pos,
                           node_color=node_color,
                           alpha=0.6,
                           node_size=node_size,
                           cmap=plt.get_cmap(colormap))
    nx.draw_networkx_edges(graph, pos, alpha=0.5)
    plt.show()


# draw a whole set of graphs:: 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:33,代码来源:__init__.py

示例13: plot_precision_recall_curve

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def plot_precision_recall_curve(y_true, y_score, size=None):
    """plot_precision_recall_curve."""
    precision, recall, thresholds = precision_recall_curve(y_true, y_score)
    if size is not None:
        plt.figure(figsize=(size, size))
        plt.axis('equal')
    plt.plot(recall, precision, lw=2, color='navy')
    plt.xlabel('Recall')
    plt.ylabel('Precision')
    plt.ylim([-0.05, 1.05])
    plt.xlim([-0.05, 1.05])
    plt.grid()
    plt.title('Precision-Recall AUC={0:0.2f}'.format(average_precision_score(
        y_true, y_score))) 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:16,代码来源:__init__.py

示例14: _cut_windows_horizontally

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def _cut_windows_horizontally(self, s, win_strip):
        win_horizontal_scores = []
        if len(self.heights) > 0:
            win_horizontal_scores = np.percentile(win_strip[self.top:self.bottom], 85, axis=0)
            runs, starts, values = run_length_encode(win_horizontal_scores > 0.5)
            starts += s
            win_widths = runs[np.atleast_1d(values)]
            win_widths = np.atleast_1d(win_widths)
            win_lefts = np.atleast_1d(starts[values])
            if len(win_widths) > 0:
                win_left = win_lefts[0]
                win_right = win_lefts[-1] + win_widths[-1]
                win_horizontal_spacing = np.diff(win_lefts).mean() if len(win_lefts) > 1 else 0
                # win_width = win_widths.mean()
            else:
                win_left = win_right = win_horizontal_spacing = -1  # win_width = -1
        else:
            win_widths = win_lefts = []
            win_left = win_right = win_horizontal_spacing = -1

        self.horizontal_spacing = int(win_horizontal_spacing)
        self.left = int(win_left)
        self.right = int(win_right)
        self.horizontal_scores = win_horizontal_scores
        self.lefts = np.array(win_lefts)
        self.widths = np.array(win_widths) 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:28,代码来源:megafacade.py

示例15: _create_mini_facade

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import axis [as 别名]
def _create_mini_facade(self, left, right, wall_colors):
        door_strip = i12.door(self.facade_layers)[:, left:right].copy()
        shop_strip = i12.shop(self.facade_layers)[:, left:right]
        door_strip = np.max((door_strip, shop_strip), axis=0)
        win_strip = self.window_scores[:, left:right].copy()
        sky_strip = self._sky_mask[:, left:right].copy()
        rgb_strip = wall_colors[:, left:right]
        win_strip[:, :1] = win_strip[:, -1:] = 0  # edge effects
        sky_strip[:, :1] = sky_strip[:, -1:] = 0  # edge effects

        facade = FacadeCandidate(self, left, right, sky_strip, door_strip, win_strip, rgb_strip)
        facade.find_regions(self.facade_layers)
        return facade 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:15,代码来源:megafacade.py


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