當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.sca方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.sca方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.sca方法的具體用法?Python pyplot.sca怎麽用?Python pyplot.sca使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.sca方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dplot_1ch

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def dplot_1ch(d, func, pgrid=True, ax=None,
              figsize=(9, 4.5), fignum=None, nosuptitle=False, **kwargs):
    """Plot wrapper for single-spot measurements. Use `dplot` instead."""
    global gui_status
    if ax is None:
        fig = plt.figure(num=fignum, figsize=figsize)
        ax = fig.add_subplot(111)
    else:
        fig = ax.figure
    s = d.name
    if 'bg_mean' in d:
        s += (' BG=%.1fk' % (d.bg_mean[Ph_sel('all')][0] * 1e-3))
    if 'T' in d:
        s += (u', T=%dμs' % (d.T[0] * 1e6))
    if 'mburst' in d:
        s += (', #bu=%d' % d.num_bursts[0])
    if not nosuptitle:
        ax.set_title(s, fontsize=12)
    ax.grid(pgrid)
    plt.sca(ax)
    gui_status['first_plot_in_figure'] = True
    func(d, **kwargs)
    return ax 
開發者ID:tritemio,項目名稱:FRETBursts,代碼行數:25,代碼來源:burst_plot.py

示例2: test_given_colors_levels_and_extends

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def test_given_colors_levels_and_extends():
    _, axes = plt.subplots(2, 4)

    data = np.arange(12).reshape(3, 4)

    colors = ['red', 'yellow', 'pink', 'blue', 'black']
    levels = [2, 4, 8, 10]

    for i, ax in enumerate(axes.flatten()):
        plt.sca(ax)

        filled = i % 2 == 0.
        extend = ['neither', 'min', 'max', 'both'][i // 2]

        if filled:
            last_color = -1 if extend in ['min', 'max'] else None
            plt.contourf(data, colors=colors[:last_color], levels=levels,
                         extend=extend)
        else:
            last_level = -1 if extend == 'both' else None
            plt.contour(data, colors=colors, levels=levels[:last_level],
                        extend=extend)

        plt.colorbar() 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:test_contour.py

示例3: plot_sub_joint

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plot_sub_joint(self, func, subsample, **kwargs):
        """Draw a bivariate plot of `x` and `y`.
        Parameters
        ----------
        func : plotting callable
            This must take two 1d arrays of data as the first two
            positional arguments, and it must plot on the "current" axes.
        kwargs : key, value mappings
            Keyword argument are passed to the plotting function.
        Returns
        -------
        self : JointGrid instance
            Returns `self`.
        """
        if subsample > 0 and subsample < len(self.x):
            indexes = np.random.choice(range(len(self.x)), subsample,
                                       replace=False)
            plot_x = np.array([self.x[i] for i in indexes])
            plot_y = np.array([self.y[i] for i in indexes])
            plt.sca(self.ax_joint)
            func(plot_x, plot_y, **kwargs)
        else:
            plt.sca(self.ax_joint)
            func(self.x, self.y, **kwargs)
        return self 
開發者ID:Noahs-ARK,項目名稱:idea_relations,代碼行數:27,代碼來源:plot_functions.py

示例4: plot_state

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plot_state(self, ax, x=None, color="b", normalize=True):
        """ Plot the current state or a given state vector

        Parameters:
        -----------
        ax: Axes Object
            The axes to plot the state on
        x: 2x0 array_like[float], optional
            A state vector of the dynamics
        Returns
        -------
        ax: Axes Object
            The axes with the state plotted
        """
        if x is None:
            x = self.current_state
            if normalize:
                x, _ = self.normalize(x)
        assert len(
            x) == self.n_s, "x needs to have the same number of states as the dynamics"
        plt.sca(ax)
        ax.plot(x[0], x[1], color=color, marker="o", mew=1.2)
        return ax 
開發者ID:befelix,項目名稱:safe-exploration,代碼行數:25,代碼來源:environments.py

示例5: plot_figures

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plot_figures(figures, nrows=1, ncols=1, width_ratios=None):
    fig, axeslist = plt.subplots(ncols=ncols, nrows=nrows, gridspec_kw={'width_ratios': width_ratios})

    for ind, (title, fig) in enumerate(figures):
        axeslist.ravel()[ind].imshow(fig, cmap='gray', interpolation='nearest')
        axeslist.ravel()[ind].set_title(title)
        if TASK != 'Associative Recall' or ind == 0:
            axeslist.ravel()[ind].set_xlabel('Time ------->')
    
    if TASK == 'Associative Recall':
        plt.sca(axeslist[1])
        plt.xticks([0, 1, 2])
        plt.sca(axeslist[2])
        plt.xticks([0, 1, 2])

    if TASK == 'Copy':
        plt.sca(axeslist[1])
        plt.yticks([])

    plt.tight_layout() 
開發者ID:MarkPKCollier,項目名稱:NeuralTuringMachine,代碼行數:22,代碼來源:produce_heat_maps.py

示例6: plot_contours_in_slice

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plot_contours_in_slice(self, slice_seg, target_axis):
        """Plots contour around the data in slice (after binarization)"""

        plt.sca(target_axis)
        contour_handles = list()
        for index, label in enumerate(self.unique_labels_display):
            binary_slice_seg = slice_seg == index
            if not binary_slice_seg.any():
                continue
            ctr_h = plt.contour(binary_slice_seg,
                                levels=[cfg.contour_level, ],
                                colors=(self.color_for_label[index],),
                                linewidths=cfg.contour_line_width,
                                alpha=self.alpha_seg,
                                zorder=cfg.seg_zorder_freesurfer)
            contour_handles.append(ctr_h)

        return contour_handles 
開發者ID:raamana,項目名稱:visualqc,代碼行數:20,代碼來源:freesurfer.py

示例7: matplotformat

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def matplotformat(self, ax, plot_y, plot_name, x_max):
		plt.sca(ax)
		plot_x = [i * 5 for i in range(len(plot_y))]
		plt.xticks(np.linspace(0, x_max, (x_max // 50) + 1, dtype=np.int32))
		plt.xlabel('Epochs', fontsize=16)
		plt.ylabel('NLL by oracle', fontsize=16)
		plt.title(plot_name)
		plt.plot(plot_x, plot_y) 
開發者ID:EternalFeather,項目名稱:Generative-adversarial-Nets-in-NLP,代碼行數:10,代碼來源:adversarial_real_corpus.py

示例8: matplotformat

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def matplotformat(self, ax, plot_y, plot_name, x_max):
		plt.sca(ax)
		plot_x = [i * 5 for i in range(len(plot_y))]
		plt.xticks(np.linspace(0, x_max, (x_max // 100) + 1, dtype=np.int32))
		plt.xlabel('Epochs', fontsize=16)
		plt.ylabel('NLL by oracle', fontsize=16)
		plt.title(plot_name)
		plt.plot(plot_x, plot_y) 
開發者ID:EternalFeather,項目名稱:Generative-adversarial-Nets-in-NLP,代碼行數:10,代碼來源:adversarial.py

示例9: visualize_predictions

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def visualize_predictions(prediction_seqs, label_seqs, num_classes,
                          fig_width=6.5, fig_height_per_seq=0.5):
    """ Visualize predictions vs. ground truth.

    Args:
        prediction_seqs: A list of int NumPy arrays, each with shape
            `[duration, 1]`.
        label_seqs: A list of int NumPy arrays, each with shape `[duration, 1]`.
        num_classes: An integer.
        fig_width: A float. Figure width (inches).
        fig_height_per_seq: A float. Figure height per sequence (inches).

    Returns:
        A tuple of the created figure, axes.
    """

    num_seqs = len(label_seqs)
    max_seq_length = max([seq.shape[0] for seq in label_seqs])
    figsize = (fig_width, num_seqs*fig_height_per_seq)
    fig, axes = plt.subplots(nrows=num_seqs, ncols=1,
                             sharex=True, figsize=figsize)

    for pred_seq, label_seq, ax in zip(prediction_seqs, label_seqs, axes):
        plt.sca(ax)
        plot_label_seq(label_seq, num_classes, 1)
        plot_label_seq(pred_seq, num_classes, -1)
        ax.get_xaxis().set_visible(False)
        ax.get_yaxis().set_visible(False)
        plt.xlim(0, max_seq_length)
        plt.ylim(-2.75, 2.75)
        plt.tight_layout()

    return fig, axes 
開發者ID:rdipietro,項目名稱:miccai-2016-surgical-activity-rec,代碼行數:35,代碼來源:data.py

示例10: implot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def implot(im1, im2, im3, im4, im5, im6, im7, im8):
    m = 4
    n = 2
    ims = [im1, im2, im3, im4, im5, im6, im7, im8]
    for i in range(m*n):
        ax = plt.subplot(m, n, i+1)
        plt.sca(ax)
        plt.imshow(ims[i]) 
開發者ID:wyf2017,項目名稱:DSMnet,代碼行數:10,代碼來源:test_ssim.py

示例11: plotChart

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plotChart(self, costList, misRateList, saveFigPath):
        '''
        繪製錯分率和損失函數值隨 epoch 變化的曲線。
        :param costList: 訓練過程中每個epoch的損失函數列表
        :param misRateList: 訓練過程中每個epoch的錯分率列表
        :return:
        '''
        # 導入繪圖庫
        import matplotlib.pyplot as plt
        # 新建畫布
        plt.figure('Perceptron Cost and Mis-classification Rate',figsize=(8, 9))
        # 設定兩個子圖和位置關係
        ax1 = plt.subplot(211)
        ax2 = plt.subplot(212)

        # 選擇子圖1並繪製損失函數值折線圖及相關坐標軸
        plt.sca(ax1)
        plt.plot(xrange(1, len(costList)+1), costList, '--b*')
        plt.xlabel('Epoch No.')
        plt.ylabel('Cost')
        plt.title('Plot of Cost Function')
        plt.grid()
        ax1.legend(u"Cost", loc='best')

        # 選擇子圖2並繪製錯分率折線圖及相關坐標軸
        plt.sca(ax2)
        plt.plot(xrange(1, len(misRateList)+1), misRateList, '-r*')
        plt.xlabel('Epoch No.')
        plt.ylabel('Mis-classification Rate')
        plt.title('Plot of Mis-classification Rate')
        plt.grid()
        ax2.legend(u'Mis-classification Rate', loc='best')

        # 顯示圖像並打印和保存
        # 需要先保存再繪圖否則相當於新建了一張新空白圖像然後保存
        plt.savefig(saveFigPath)
        plt.show()

################################### PART3 TEST ########################################
# 例子 
開發者ID:ysh329,項目名稱:statistical-learning-methods-note,代碼行數:42,代碼來源:Perceptron.py

示例12: plotChart

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plotChart(self, costList, misRateList, saveFigPath):
        '''
        繪製錯分率和損失函數值隨 epoch 變化的曲線。
        :param costList: 訓練過程中每個epoch的損失函數列表
        :param misRateList: 訓練過程中每個epoch的錯分率列表
        :return:
        '''
        # 導入繪圖庫
        import matplotlib.pyplot as plt
        # 新建畫布
        plt.figure('Perceptron Cost and Mis-classification Rate', figsize=(8, 9))
        # 設定兩個子圖和位置關係
        ax1 = plt.subplot(211)
        ax2 = plt.subplot(212)

        # 選擇子圖1並繪製損失函數值折線圖及相關坐標軸
        plt.sca(ax1)
        plt.plot(xrange(1, len(costList) + 1), costList, '--b*')
        plt.xlabel('Epoch No.')
        plt.ylabel('Cost')
        plt.title('Plot of Cost Function')
        plt.grid()
        ax1.legend(u"Cost", loc='best')

        # 選擇子圖2並繪製錯分率折線圖及相關坐標軸
        plt.sca(ax2)
        plt.plot(xrange(1, len(misRateList) + 1), misRateList, '-r*')
        plt.xlabel('Epoch No.')
        plt.ylabel('Mis-classification Rate')
        plt.title('Plot of Mis-classification Rate')
        plt.grid()
        ax2.legend(u'Mis-classification Rate', loc='best')

        # 顯示圖像並打印和保存
        # 需要先保存再繪圖否則相當於新建了一張新空白圖像然後保存
        plt.savefig(saveFigPath)
        plt.show()

################################### PART3 TEST ########################################
# 例子 
開發者ID:ysh329,項目名稱:statistical-learning-methods-note,代碼行數:42,代碼來源:Dual-form_Perceptron.py

示例13: plot_ellipsoid_2D

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plot_ellipsoid_2D(p, q, ax, n_points=100, color="r"):
    """ Plot an ellipsoid in 2D

    TODO: Untested!

    Parameters
    ----------
    p: 3x1 array[float]
        Center of the ellipsoid
    q: 3x3 array[float]
        Shape matrix of the ellipsoid
    ax: matplotlib.Axes object
        Ax on which to plot the ellipsoid

    Returns
    -------
    ax: matplotlib.Axes object
        The Ax containing the ellipsoid
    """
    plt.sca(ax)
    r = nLa.cholesky(q).T;  # checks spd inside the function
    t = np.linspace(0, 2 * np.pi, n_points);
    z = [np.cos(t), np.sin(t)];
    ellipse = np.dot(r, z) + p;
    handle, = ax.plot(ellipse[0, :], ellipse[1, :], color)

    return ax, handle 
開發者ID:befelix,項目名稱:safe-exploration,代碼行數:29,代碼來源:utils_visualization.py

示例14: plot_ellipsoid_trajectory

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plot_ellipsoid_trajectory(self, p, q, vis_safety_bounds=True, ax=None,
                                  color="r"):
        """ Plot the reachability ellipsoids given in observation space

        TODO: Need more principled way to transform ellipsoid to internal states

        Parameters
        ----------
        p: n x n_s array[float]
            The ellipsoid centers of the trajectory
        q: n x n_s x n_s  ndarray[float]
            The shape matrices of the trajectory
        vis_safety_bounds: bool, optional
            Visualize the safety bounds of the system

        """
        new_ax = False

        if ax is None:
            fig = plt.figure()
            ax = fig.add_subplot(111)
            new_ax = True

        plt.sca(ax)
        n, n_s = np.shape(p)
        handles = [None] * n
        for i in range(n):
            p_i = cas_reshape(p[i, :], (n_s, 1)) + self.p_origin.reshape((n_s, 1))
            q_i = cas_reshape(q[i, :], (self.n_s, self.n_s))
            ax, handles[i] = plot_ellipsoid_2D(p_i, q_i, ax, color=color)
            # ax = plot_ellipsoid_2D(p_i,q_i,ax,color = color)

        if vis_safety_bounds:
            ax = self.plot_safety_bounds(ax)

        if new_ax:
            plt.show()

        return ax, handles 
開發者ID:befelix,項目名稱:safe-exploration,代碼行數:41,代碼來源:environments.py

示例15: plot_ellipsoid_2D

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import sca [as 別名]
def plot_ellipsoid_2D(p, q, ax, n_points = 100, color = "r"):
    """ Plot an ellipsoid in 2D

    TODO: Untested!

    Parameters
    ----------
    p: 3x1 array[float]
        Center of the ellipsoid
    q: 3x3 array[float]
        Shape matrix of the ellipsoid
    ax: matplotlib.Axes object
        Ax on which to plot the ellipsoid

    Returns
    -------
    ax: matplotlib.Axes object
        The Ax containing the ellipsoid
    """
    plt.sca(ax)
    r = nLa.cholesky(q).T; #checks spd inside the function
    t = np.linspace(0, 2*np.pi, n_points);
    z = [np.cos(t), np.sin(t)];
    ellipse = np.dot(r,z) + p;
    handle, = ax.plot(ellipse[0,:], ellipse[1,:],color)

    return ax, handle 
開發者ID:befelix,項目名稱:safe-exploration,代碼行數:29,代碼來源:utils_visualization.py


注:本文中的matplotlib.pyplot.sca方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。