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


Python pylab.axis方法代码示例

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


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

示例1: modbc

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def modbc(self):
        self.resorx = 0.0
        self.resory = 0.0

        for i in range(2, self.ni):
            xp = self.x(i, nj - 1)
            yp = self.y(i, nj - 1)
            xb = self.x(i, nj)
            yb = self.y(i, nj)
            ifail = 0
            call e02bcf(nicap7, xkn, cn, xb, 1, sn, ifail)
            interpolate.CubicSpline(x, y, axis=0, bc_type='not-a-knot', extrapolate=None)
            dydxb = min(sn(2), 1.d10)
            dydxb = max(sn(2), 1.d-10)
            if(sn(2).lt.0.0) dydxb = max(sn(2), -1.d10)
            if(sn(2).lt.0.0) dydxb = min(sn(2), -1.d-10)
            x(i, nj) = (yb-yp-xb*dydxb-xp/dydxb)/(-dydxb-1.0/dydxb)
            ifail = 0.0
            call e02bcf(nicap7, xkn, cn, x(i, nj), 1, sn, ifail)
            y(i, nj) = sn(1)
            resxb = abs(xb-x(i, nj))/xl
            resorx = resorx+resxb
            resyb = abs(yb-y(i, nj))/yl
            resory = resory+resyb 
开发者ID:chiefenne,项目名称:PyAero,代码行数:26,代码来源:Orthogonal.py

示例2: _show_video

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def _show_video(video, fps=10):
    # Import matplotlib/pylab only if needed
    import matplotlib
    matplotlib.use('TkAgg')
    import matplotlib.pylab as pl
    pl.style.use('ggplot')
    pl.axis('off')

    if fps < 0:
        fps = 25
    video /= 255.  # Pylab works in [0, 1] range
    img = None
    pause_length = 1. / fps
    try:
        for f in range(video.shape[0]):
            im = video[f, :, :, :]
            if img is None:
                img = pl.imshow(im)
            else:
                img.set_data(im)
            pl.pause(pause_length)
            pl.draw()
    except:
        pass 
开发者ID:victorcampos7,项目名称:tensorflow-ffmpeg,代码行数:26,代码来源:usage_example.py

示例3: get

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def get(self,t1,t2):
        t,v = self.stream.get_tsvs(t1-2.0*self.dt,t2+2.0*self.dt)
        try:
            return interp1d(t,
                        v.reshape(len(t),-1),
                        axis=0,
                        fill_value='extrapolate',
                        bounds_error = False
                       )(self.ts(t1,t2)).reshape(
            [len(self.ts(t1,t2))]+list(v.shape[1:]))
        except ValueError:
            # old versions of scipy don't know extrapolate
            # it also doesn't behave as numpy interpolate (extending the first and last values) as only one value is accepted
            # this should not be a problem if we 2*dt before and after the time slice
            return interp1d(t,
                        v.reshape(len(t),-1),
                        axis=0,
                        fill_value=np.mean(v),
                        bounds_error = False
                       )(self.ts(t1,t2)).reshape(
            [len(self.ts(t1,t2))]+list(v.shape[1:])) 
开发者ID:jahuth,项目名称:convis,代码行数:23,代码来源:streams.py

示例4: _repr_html_

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def _repr_html_(self):
        from . import variable_describe
        def _plot(fn):
            from PIL import Image
            try:
                import matplotlib.pylab as plt
                t = np.array(Image.open(fn))
                plt.figure()
                plt.imshow(self._crop(t))
                plt.axis('off')
                return "<img src='data:image/png;base64," + variable_describe._plot_to_string() + "'>"
            except:
                return "<br/>Failed to open."
        s = "<b>ImageSequence</b> size="+str(self.size)
        s += ", offset = "+str(self.offset)
        s += ", repeat = "+str(self.repeat)
        s += ", is_color = "+str(self.is_color)
        s += ", [frame "+str(self.i)+"/"+str(len(self))+"]"
        s += "<div style='background:#ff;padding:10px'><b>Input Images:</b>"
        for t in np.unique(self.file_list)[:10]:
            s += "<div style='background:#fff; margin:10px;padding:10px; border-left: 4px solid #eee;'>"+str(t)+": "+_plot(t)+"</div>"
        s += "</div>"
        return s 
开发者ID:jahuth,项目名称:convis,代码行数:25,代码来源:streams.py

示例5: get_one_frame

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def get_one_frame(self):
        file_list = list(np.repeat(self.file_list,self.repeat))
        if file_list[self.i] in self.cache.keys():
            frame = self.cache[file_list[self.i]]
        else:
            from PIL import Image
            frame = np.array(Image.open(file_list[self.i]))
            if not self.is_color and len(frame.shape) > 2:
                frame = frame.mean(2)
            if self.is_color:
                if len(frame.shape) == 2:
                    print('2 to 3d')
                    frame = frame[:,:,None]
                if frame.shape[2] < 3:
                    frame = np.repeat(frame[:,:,None],3,axis=2)
                if frame.shape[2] > 3:
                    frame = frame[:,:,:3]
            self.cache[file_list[self.i]] = frame
        cropped_frame = self._crop(frame)
        self.last_image = cropped_frame
        self.i += 1
        return cropped_frame 
开发者ID:jahuth,项目名称:convis,代码行数:24,代码来源:streams.py

示例6: format_array

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def format_array(arr):
    """
    Utility to format array for tiled plot

    args: arr (numpy array)
            shape : (n_samples, n_channels, img_dim1, img_dim2)
    """
    n_channels = arr.shape[1]
    len_arr = arr.shape[0]
    assert (n_channels == 1 or n_channels == 3), "n_channels should be 1 (Greyscale) or 3 (Color)"
    if n_channels == 1:
        arr = np.repeat(arr, 3, axis=1)

    shape1, shape2 = arr.shape[-2:]
    arr = np.transpose(arr, [1, 0, 2, 3])
    arr = arr.reshape([3, len_arr, shape1 * shape2]).astype(np.float64)
    arr = tuple([arr[i] for i in xrange(3)] + [None])
    return arr, shape1, shape2 
开发者ID:tdeboissiere,项目名称:DeepLearningImplementations,代码行数:20,代码来源:utils.py

示例7: format_plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def format_plot(X, epoch=None, title=None, figsize=(15, 10)):

    plt.figure(figsize=figsize)

    if X.shape[-1] == 1:
        plt.imshow(X[:, :, 0], cmap="gray")
    else:
        plt.imshow(X)

    plt.axis("off")
    plt.gca().xaxis.set_major_locator(mp.ticker.NullLocator())
    plt.gca().yaxis.set_major_locator(mp.ticker.NullLocator())

    if epoch is not None and title is None:
        save_path = os.path.join(FLAGS.fig_dir, "current_batch_%s.png" % epoch)
    elif epoch is not None and title is not None:
        save_path = os.path.join(FLAGS.fig_dir, "%s_%s.png" % (title, epoch))
    elif title is not None:
        save_path = os.path.join(FLAGS.fig_dir, "%s.png" % title)
    plt.savefig(save_path, bbox_inches='tight', pad_inches=0)
    plt.clf()
    plt.close() 
开发者ID:tdeboissiere,项目名称:DeepLearningImplementations,代码行数:24,代码来源:visualization_utils.py

示例8: tsne_plot

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def tsne_plot(xs, xt, xs_label, xt_label, subset=True, title=None, pname=None):
    num_test=1000
    import matplotlib.cm as cm
    if subset:
        combined_imgs = np.vstack([xs[0:num_test, :], xt[0:num_test, :]])
        combined_labels = np.vstack([xs_label[0:num_test, :],xt_label[0:num_test, :]])
        combined_labels = combined_labels.astype('int')
        combined_domain = np.vstack([np.zeros((num_test,1)),np.ones((num_test,1))])
    
    from sklearn.manifold import TSNE
    tsne = TSNE(perplexity=30, n_components=2, init='pca', n_iter=3000)
    source_only_tsne = tsne.fit_transform(combined_imgs)
    plt.figure(figsize=(15,15))
    plt.scatter(source_only_tsne[:num_test,0], source_only_tsne[:num_test,1], c=combined_labels[:num_test].argmax(1),
                s=50, alpha=0.5,marker='o', cmap=cm.jet, label='source')
    plt.scatter(source_only_tsne[num_test:,0], source_only_tsne[num_test:,1], c=combined_labels[num_test:].argmax(1),
                s=50, alpha=0.5,marker='+',cmap=cm.jet,label='target')
    plt.axis('off')
    plt.legend(loc='best')
    plt.title(title)
    if filesave:
        plt.savefig(os.path.join(pname,title+'.png'),bbox_inches='tight', pad_inches = 0,
                    format='png')
    else:
        plt.savefig(title+'.png')
    plt.close() 


#%% source model 
开发者ID:bbdamodaran,项目名称:deepJDOT,代码行数:31,代码来源:deepjdot_svhn_mnist.py

示例9: imshow_

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def imshow_(x, **kwargs):
    if x.ndim == 2:
        plt.imshow(x, interpolation="nearest", **kwargs)
    elif x.ndim == 1:
        plt.imshow(x[:, None].T, interpolation="nearest", **kwargs)
        plt.yticks([])
    plt.axis("tight")


# ------------- Data ------------- 
开发者ID:Zephyr-D,项目名称:TCFPN-ISBA,代码行数:12,代码来源:utils.py

示例10: plot1D_mat

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def plot1D_mat(a, b, M, title=''):
    """ Plot matrix M  with the source and target 1D distribution

    Creates a subplot with the source distribution a on the left and
    target distribution b on the tot. The matrix M is shown in between.


    Parameters
    ----------
    a : ndarray, shape (na,)
        Source distribution
    b : ndarray, shape (nb,)
        Target distribution
    M : ndarray, shape (na, nb)
        Matrix to plot
    """
    na, nb = M.shape

    gs = gridspec.GridSpec(3, 3)

    xa = np.arange(na)
    xb = np.arange(nb)

    ax1 = pl.subplot(gs[0, 1:])
    pl.plot(xb, b, 'r', label='Target distribution')
    pl.yticks(())
    pl.title(title)

    ax2 = pl.subplot(gs[1:, 0])
    pl.plot(a, xa, 'b', label='Source distribution')
    pl.gca().invert_xaxis()
    pl.gca().invert_yaxis()
    pl.xticks(())

    pl.subplot(gs[1:, 1:], sharex=ax1, sharey=ax2)
    pl.imshow(M, interpolation='nearest')
    pl.axis('off')

    pl.xlim((0, nb))
    pl.tight_layout()
    pl.subplots_adjust(wspace=0., hspace=0.2) 
开发者ID:PythonOT,项目名称:POT,代码行数:43,代码来源:plot.py

示例11: _gradient_windowed

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def _gradient_windowed(X, points_window, axis):
    '''
    Calculate the gradient using an arbitrary window. The larger window make 
    this procedure less noisy that the numpy native gradient.
    '''
    w_s = 2*points_window
    
    #I use slices to deal with arbritary dimenssions 
    #https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
    n_axis_ini = max(0, axis)
    n_axis_fin = max(0, X.ndim-axis-1)
    
    right_slice = [slice(None, None, None)]*n_axis_ini + [slice(None, -w_s, None)]
    right_slice = tuple(right_slice)
    
    left_slice = [slice(None, None, None)]*n_axis_ini + [slice(w_s, None, None)]
    left_slice = tuple(left_slice)

    right_pad = [(0,0)]*n_axis_ini + [(w_s, 0)] + [(0,0)]*n_axis_fin
    left_pad = [(0,0)]*n_axis_ini + [(0, w_s)] + [(0,0)]*n_axis_fin
    
    right_side = np.pad(X[right_slice], right_pad, 'edge')
    left_side = np.pad(X[left_slice], left_pad, 'edge')
    
    ramp = np.full(X.shape[axis]-2*w_s, w_s*2)
    
    ramp = np.pad(ramp,  pad_width = (w_s, w_s),  mode='linear_ramp', end_values = w_s)
    #ramp = np.pad(ramp,  pad_width = (w_s, w_s),  mode='constant', constant_values = np.nan)
    ramp_slice = [None]*n_axis_ini + [slice(None, None, None)] + [None]*n_axis_fin
    ramp_slice = tuple(ramp_slice)

    grad = (left_side - right_side) / ramp[ramp_slice] #divide it by the time window
    
    return grad 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:36,代码来源:curvatures.py

示例12: _h_smooth_cnt

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def _h_smooth_cnt(food_cnt, resampling_N = 1000, smooth_window=None, _is_debug=False):
    if smooth_window is None:
        smooth_window = resampling_N//20
    
    if not _is_valid_cnt(food_cnt):
        #invalid contour arrays
        return food_cnt
        
    smooth_window = smooth_window if smooth_window%2 == 1 else smooth_window+1
    # calculate the cumulative length for each segment in the curve
    dx = np.diff(food_cnt[:, 0])
    dy = np.diff(food_cnt[:, 1])
    dr = np.sqrt(dx * dx + dy * dy)
    lengths = np.cumsum(dr)
    lengths = np.hstack((0, lengths))  # add the first point
    tot_length = lengths[-1]
    fx = interp1d(lengths, food_cnt[:, 0])
    fy = interp1d(lengths, food_cnt[:, 1])
    subLengths = np.linspace(0 + np.finfo(float).eps, tot_length, resampling_N)
    
    rx = fx(subLengths)
    ry = fy(subLengths)
    
    pol_degree = 3
    rx = savgol_filter(rx, smooth_window, pol_degree, mode='wrap')
    ry = savgol_filter(ry, smooth_window, pol_degree, mode='wrap')
    
    food_cnt_s = np.stack((rx, ry), axis=1)
    
    if _is_debug:
        import matplotlib.pylab as plt
        plt.figure()
        plt.plot(food_cnt[:, 0], food_cnt[:, 1], '.-')
        plt.plot(food_cnt_s[:, 0], food_cnt_s[:, 1], '.-')
        plt.axis('equal')
        plt.title('smoothed contour')
    
    return food_cnt_s

#%% 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:42,代码来源:food.py

示例13: _h_get_unit_vec

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def _h_get_unit_vec(x):
    return x/np.linalg.norm(x, axis=1)[:, np.newaxis]
#%% 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:5,代码来源:food.py

示例14: put

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def put(self,s):
        if self.sequence.shape[1:] == s.shape[1:]:
            if len(self.sequence) + len(s) > self.max_frames:
                self.sequence = np.concatenate([self.sequence,s],axis=0)[-self.max_frames:]
            else:
                self.sequence = np.concatenate([self.sequence,s],axis=0)
        else:
            if len(s) > self.max_frames:
                self.sequence = s[-self.max_frames:]
            else:
                self.sequence = s 
开发者ID:jahuth,项目名称:convis,代码行数:13,代码来源:streams.py

示例15: update_image

# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import axis [as 别名]
def update_image(self):
        from PIL import Image, ImageTk
        if self.decay_activity is not None:
            try:
                da = self.decay_activity
                da = da + np.min(da)
                im = da/max(np.max(da),1.0)
                im = im.clip(0.0,1.0)
                if im.shape[0] < 50:
                    im = np.repeat(im,10,axis=0)
                    im = np.repeat(im,10,axis=1)
                elif im.shape[0] < 100:
                    im = np.repeat(im,5,axis=0)
                    im = np.repeat(im,5,axis=1)
                elif im.shape[0] < 300:
                    im = np.repeat(im,2,axis=0)
                    im = np.repeat(im,2,axis=1)
                if self.cmap is not None:
                    self.image = Image.fromarray(self.cmap(im, bytes=True))
                else:
                    self.image = Image.fromarray(256.0*im).convert('RGB')#Image.open(image_buffer)#cStringIO.StringIO(self.last_buffer))
                #self.image.resize((500,500), Image.ANTIALIAS)
                #self.image.load()
                self.image1 = ImageTk.PhotoImage(self.image)
                self.panel1.configure(image=self.image1)
                self.root.title(str(len(self.last_buffer))+' Images buffered')
                self.display = self.image1
            except Exception as e:
                #print(e)
                raise
                #pass
        self.root.after(int(50), self.update_image) 
开发者ID:jahuth,项目名称:convis,代码行数:34,代码来源:streams.py


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