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


Python pyplot.figaspect方法代碼示例

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


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

示例1: generateImage

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def generateImage(self, filename):
    """ Generate a heatmap of the probe
    """
    data = list()
    for y in sorted(self.yvals, reverse = True):
      line = list()
      for x in self.xvals:
        line.append(self.pdict[x][y] - self.median)
      data.append(line)
    my_data = np.array(data)
    fig = plt.figure(figsize=plt.figaspect(0.5))
    plt.subplot(1, 1, 1, xticks = [], yticks = [])
    plt.imshow(my_data, cmap = 'copper')
    plt.colorbar()
    fig.set_size_inches((16, 8))
    plt.savefig(filename, dpi = 100)

#--- Main program 
開發者ID:thegaragelab,項目名稱:gctools,代碼行數:20,代碼來源:probeinfo.py

示例2: _plot_and_save_attention

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def _plot_and_save_attention(att_w, filename):
    """Plot and save an attention."""
    # dynamically import matplotlib due to not found error
    from matplotlib.ticker import MaxNLocator
    import os

    d = os.path.dirname(filename)
    if not os.path.exists(d):
        os.makedirs(d)
    w, h = plt.figaspect(1.0 / len(att_w))
    fig = plt.Figure(figsize=(w * 2, h * 2))
    axes = fig.subplots(1, len(att_w))
    if len(att_w) == 1:
        axes = [axes]
    for ax, aw in zip(axes, att_w):
        # plt.subplot(1, len(att_w), h)
        ax.imshow(aw, aspect="auto")
        ax.set_xlabel("Input")
        ax.set_ylabel("Output")
        ax.xaxis.set_major_locator(MaxNLocator(integer=True))
        ax.yaxis.set_major_locator(MaxNLocator(integer=True))
    fig.tight_layout()
    return fig 
開發者ID:espnet,項目名稱:espnet,代碼行數:25,代碼來源:plot.py

示例3: _plot_and_save_attention

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def _plot_and_save_attention(att_w, filename):
    # dynamically import matplotlib due to not found error
    from matplotlib.ticker import MaxNLocator
    import os
    d = os.path.dirname(filename)
    if not os.path.exists(d):
        os.makedirs(d)
    w, h = plt.figaspect(1.0 / len(att_w))
    fig = plt.Figure(figsize=(w * 2, h * 2))
    axes = fig.subplots(1, len(att_w))
    if len(att_w) == 1:
        axes = [axes]
    for ax, aw in zip(axes, att_w):
        # plt.subplot(1, len(att_w), h)
        ax.imshow(aw.astype(numpy.float32), aspect="auto")
        ax.set_xlabel("Input")
        ax.set_ylabel("Output")
        ax.xaxis.set_major_locator(MaxNLocator(integer=True))
        ax.yaxis.set_major_locator(MaxNLocator(integer=True))
    fig.tight_layout()
    return fig 
開發者ID:DigitalPhonetics,項目名稱:adviser,代碼行數:23,代碼來源:plot.py

示例4: plot_2d_3d

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def plot_2d_3d(self, pose_2d_x, pose_2d_y,
                         pose_3d_x, pose_3d_y, pose_3d_z, kpts_v, BLOCK=True):

        fig = plt.figure(figsize=plt.figaspect(.5))
        plt.clf()
        ax_2d = fig.add_subplot(1, 2, 1)
        self.plot_2d(pose_2d_x, pose_2d_y, kpts_v, BLOCK, ax_2d)

        ax_3d = fig.add_subplot(1, 2, 2, projection='3d')
        self.plot_3d(pose_3d_x, pose_3d_y, pose_3d_z, kpts_v, BLOCK, ax_3d)

        if BLOCK:
            plt.show()
            #plt.close()
        else:
            plt.draw()
            plt.pause(0.01) 
開發者ID:matteorr,項目名稱:rel_3d_pose,代碼行數:19,代碼來源:pose_plotter.py

示例5: test_figaspect

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def test_figaspect():
    w, h = plt.figaspect(np.float64(2) / np.float64(1))
    assert h / w == 2
    w, h = plt.figaspect(2)
    assert h / w == 2
    w, h = plt.figaspect(np.zeros((1, 2)))
    assert h / w == 0.5
    w, h = plt.figaspect(np.zeros((2, 2)))
    assert h / w == 1 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:11,代碼來源:test_figure.py

示例6: show_image

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def show_image(image, landmarks, box=None):
    fig = plt.figure(figsize=plt.figaspect(.5))
    ax = fig.add_subplot(1, 1, 1)
    ax.imshow(image)
    num_points = landmarks.shape[0]
    if num_points == 68:
        ax.plot(landmarks[0:17,0],landmarks[0:17,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[17:22,0],landmarks[17:22,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[22:27,0],landmarks[22:27,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[27:31,0],landmarks[27:31,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[31:36,0],landmarks[31:36,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[36:42,0],landmarks[36:42,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[42:48,0],landmarks[42:48,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[48:60,0],landmarks[48:60,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[60:68,0],landmarks[60:68,1],marker='o',markersize=4,linestyle='-',color='w',lw=2) 
    elif num_points == 98:
        ax.plot(landmarks[0:33,0],landmarks[0:33,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[33:38,0],landmarks[33:38,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[37:42,0],landmarks[37:42,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[42:46,0],landmarks[42:46,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[45:51,0],landmarks[45:51,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[51:55,0],landmarks[51:55,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[55:60,0],landmarks[55:60,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[60:65,0],landmarks[60:65,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[64:68,0],landmarks[64:68,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[68:73,0],landmarks[68:73,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[72:76,0],landmarks[72:76,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[76:83,0],landmarks[76:83,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[82:88,0],landmarks[82:88,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[88:93,0],landmarks[88:93,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[92:96,0],landmarks[92:96,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[96,0],landmarks[96,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
        ax.plot(landmarks[97,0],landmarks[97,1],marker='o',markersize=4,linestyle='-',color='w',lw=2)
    if box is not None:
        currentAxis=plt.gca()
        box = enlarge_box(box,0.05)
        xmin, ymin, xmax, ymax = box
        rect=patches.Rectangle((xmin, ymin),xmax-xmin,ymax-ymin,linewidth=2,edgecolor='r',facecolor='none')
        currentAxis.add_patch(rect)
    ax.axis('off')
    plt.show() 
開發者ID:face-alignment-group-of-ahucs,項目名稱:SHN-based-2D-face-alignment,代碼行數:43,代碼來源:utils.py

示例7: _plot_and_save_attention

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def _plot_and_save_attention(att_w, filename, xtokens=None, ytokens=None):
    # dynamically import matplotlib due to not found error
    from matplotlib.ticker import MaxNLocator
    import os

    d = os.path.dirname(filename)
    if not os.path.exists(d):
        os.makedirs(d)
    w, h = plt.figaspect(1.0 / len(att_w))
    fig = plt.Figure(figsize=(w * 2, h * 2))
    axes = fig.subplots(1, len(att_w))
    if len(att_w) == 1:
        axes = [axes]
    for ax, aw in zip(axes, att_w):
        # plt.subplot(1, len(att_w), h)
        ax.imshow(aw.astype(numpy.float32), aspect="auto")
        ax.set_xlabel("Input")
        ax.set_ylabel("Output")
        ax.xaxis.set_major_locator(MaxNLocator(integer=True))
        ax.yaxis.set_major_locator(MaxNLocator(integer=True))
        # Labels for major ticks
        if xtokens is not None:
            ax.set_xticks(numpy.linspace(0, len(xtokens) - 1, len(xtokens)))
            ax.set_xticks(numpy.linspace(0, len(xtokens) - 1, 1), minor=True)
            ax.set_xticklabels(xtokens + [""], rotation=40)
        if ytokens is not None:
            ax.set_yticks(numpy.linspace(0, len(ytokens) - 1, len(ytokens)))
            ax.set_yticks(numpy.linspace(0, len(ytokens) - 1, 1), minor=True)
            ax.set_yticklabels(ytokens + [""])
    fig.tight_layout()
    return fig 
開發者ID:espnet,項目名稱:espnet,代碼行數:33,代碼來源:plot.py

示例8: finalize

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def finalize(self):
        super().finalize()
        self.ax.autoscale(True)
        if self._adjust_figure:
            minx, maxx = self.ax.get_xlim()
            miny, maxy = self.ax.get_ylim()
            data_width, data_height = maxx - minx, maxy - miny
            if not math.isclose(data_width, 0):
                width, height = plt.figaspect(data_height / data_width)
                self.ax.get_figure().set_size_inches(width, height, forward=True) 
開發者ID:mozman,項目名稱:ezdxf,代碼行數:12,代碼來源:matplotlib_backend.py

示例9: plot_train_progress

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def plot_train_progress(scores, img_title, save_path, show, names=None):
    """
    A plotting function using the array of loss values saved while training.
    :param train_losses, dev_losses: losses saved during training
    :return:
    """

    nrows, ncols = 2, 3
    dx, dy = 2, 1
    num_iter = len(scores[0])
    xs = np.arange(start=1, stop=num_iter + 1, step=1)
    figsize = plt.figaspect(float(dy * nrows) / float(dx * ncols))
    fig, axes = plt.subplots(nrows, ncols, figsize=figsize)
    fig.suptitle(img_title)

    for sc, ax, name in zip(scores, axes.flat, names):

        # Set label for the X axis
        ax.set_xlabel('EpochN', fontsize=12)

        if type(name) in [list, tuple]:  # this should happen with loss plotting only
            # It means that scores are represented as an MxN Numpy array
            num_curves = sc.shape[1]
            for idx in range(num_curves):
                ax.plot(xs, sc[:, idx])

            ax.xaxis.set_major_locator(ticker.MultipleLocator(1))
            ax.legend(name)  # name is a list -> need to create a legend for this subplot
            ax.set_ylabel('Loss', fontsize=12)

        else:
            ax.plot(xs, sc)
            ax.xaxis.set_major_locator(ticker.MultipleLocator(1))
            ax.set_ylabel(name, fontsize=12)

    plt.legend(loc='best', fancybox=True, framealpha=0.5)
    pad = 0.05  # Padding around the edge of the figure
    xpad, ypad = dx * pad, dy * pad
    fig.tight_layout(pad=2, h_pad=xpad, w_pad=xpad)

    if save_path is not None:
        logger.debug("Saving the learning curve plot --> %s" % save_path)
        fig.savefig(save_path)

    if show:
        plt.show() 
開發者ID:UKPLab,項目名稱:e2e-nlg-challenge-2017,代碼行數:48,代碼來源:visualize.py

示例10: plot_sphere_func2

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def plot_sphere_func2(f, grid='Clenshaw-Curtis', beta=None, alpha=None, colormap='jet', fignum=0,  normalize=True):
    # TODO: update this  function now that we have changed the order of axes in f
    import matplotlib.pyplot as plt
    from matplotlib import cm, colors
    from mpl_toolkits.mplot3d import Axes3D
    import numpy as np
    from scipy.special import sph_harm

    if normalize:
        f = (f - np.min(f)) / (np.max(f) - np.min(f))

    if grid == 'Driscoll-Healy':
        b = f.shape[0] // 2
    elif grid == 'Clenshaw-Curtis':
        b = (f.shape[0] - 2) // 2
    elif grid == 'SOFT':
        b = f.shape[0] // 2
    elif grid == 'Gauss-Legendre':
        b = (f.shape[0] - 2) // 2

    if beta is None or alpha is None:
        beta, alpha = meshgrid(b=b, grid_type=grid)

    alpha = np.r_[alpha, alpha[0, :][None, :]]
    beta = np.r_[beta, beta[0, :][None, :]]
    f = np.r_[f, f[0, :][None, :]]

    x = np.sin(beta) * np.cos(alpha)
    y = np.sin(beta) * np.sin(alpha)
    z = np.cos(beta)

    # m, l = 2, 3
    # Calculate the spherical harmonic Y(l,m) and normalize to [0,1]
    # fcolors = sph_harm(m, l, beta, alpha).real
    # fmax, fmin = fcolors.max(), fcolors.min()
    # fcolors = (fcolors - fmin) / (fmax - fmin)
    print(x.shape, f.shape)

    if f.ndim == 2:
        f = cm.gray(f)
        print('2')

    # Set the aspect ratio to 1 so our sphere looks spherical
    fig = plt.figure(figsize=plt.figaspect(1.))
    ax = fig.add_subplot(111, projection='3d')
    ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=f ) # cm.gray(f))
    # Turn off the axis planes
    ax.set_axis_off()
    plt.show() 
開發者ID:AMLab-Amsterdam,項目名稱:lie_learn,代碼行數:51,代碼來源:S2.py

示例11: plot_bloch_multivector

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def plot_bloch_multivector(rho, title='', figsize=None):
    """Plot the Bloch sphere.

    Plot a sphere, axes, the Bloch vector, and its projections onto each axis.

    Args:
        rho (ndarray): Numpy array for state vector or density matrix.
        title (str): a string that represents the plot title
        figsize (tuple): Has no effect, here for compatibility only.

    Returns:
        matplotlib.Figure:
            A matplotlib figure instance.

    Raises:
        ImportError: Requires matplotlib.

    Example:
        .. jupyter-execute::

            from qiskit import QuantumCircuit, BasicAer, execute
            from qiskit.visualization import plot_bloch_multivector
            %matplotlib inline

            qc = QuantumCircuit(2, 2)
            qc.h(0)
            qc.cx(0, 1)
            qc.measure([0, 1], [0, 1])

            backend = BasicAer.get_backend('statevector_simulator')
            job = execute(qc, backend).result()
            plot_bloch_multivector(job.get_statevector(qc), title="New Bloch Multivector")
    """
    if not HAS_MATPLOTLIB:
        raise ImportError('Must have Matplotlib installed. To install, run "pip install '
                          'matplotlib".')
    rho = _validate_input_state(rho)
    num = int(np.log2(len(rho)))
    width, height = plt.figaspect(1/num)
    fig = plt.figure(figsize=(width, height))
    for i in range(num):
        ax = fig.add_subplot(1, num, i + 1, projection='3d')
        pauli_singles = [
            Pauli.pauli_single(num, i, 'X'),
            Pauli.pauli_single(num, i, 'Y'),
            Pauli.pauli_single(num, i, 'Z')
        ]
        bloch_state = list(
            map(lambda x: np.real(np.trace(np.dot(x.to_matrix(), rho))),
                pauli_singles))
        plot_bloch_vector(bloch_state, "qubit " + str(i), ax=ax,
                          figsize=figsize)
    fig.suptitle(title, fontsize=16)
    if get_backend() in ['module://ipykernel.pylab.backend_inline',
                         'nbAgg']:
        plt.close(fig)
    return fig 
開發者ID:Qiskit,項目名稱:qiskit-terra,代碼行數:59,代碼來源:state_visualization.py

示例12: draw_landmarks

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def draw_landmarks():
    filelists = 'test.data/AFLW2000-3D_crop.list'
    root = 'AFLW-2000-3D/'
    fns = open(filelists).read().strip().split('\n')
    params = _load('res/params_aflw2000.npy')

    for i in range(2000):
        plt.close()
        img_fp = osp.join(root, fns[i])
        img = io.imread(img_fp)
        lms = reconstruct_vertex(params[i], dense=False)
        lms = convert_to_ori(lms, i)

        # print(lms.shape)
        fig = plt.figure(figsize=plt.figaspect(.5))
        # fig = plt.figure(figsize=(8, 4))
        ax = fig.add_subplot(1, 2, 1)
        ax.imshow(img)

        alpha = 0.8
        markersize = 4
        lw = 1.5
        color = 'w'
        markeredgecolor = 'black'

        nums = [0, 17, 22, 27, 31, 36, 42, 48, 60, 68]
        for ind in range(len(nums) - 1):
            l, r = nums[ind], nums[ind + 1]
            ax.plot(lms[0, l:r], lms[1, l:r], color=color, lw=lw, alpha=alpha - 0.1)

            ax.plot(lms[0, l:r], lms[1, l:r], marker='o', linestyle='None', markersize=markersize, color=color,
                    markeredgecolor=markeredgecolor, alpha=alpha)

        ax.axis('off')

        # 3D
        ax = fig.add_subplot(1, 2, 2, projection='3d')
        lms[1] = img.shape[1] - lms[1]
        lms[2] = -lms[2]

        # print(lms)
        ax.scatter(lms[0], lms[2], lms[1], c="cyan", alpha=1.0, edgecolor='b')

        for ind in range(len(nums) - 1):
            l, r = nums[ind], nums[ind + 1]
            ax.plot3D(lms[0, l:r], lms[2, l:r], lms[1, l:r], color='blue')

        ax.view_init(elev=5., azim=-95)
        # ax.set_xlabel('x')
        # ax.set_ylabel('y')
        # ax.set_zlabel('z')

        ax.set_xticklabels([])
        ax.set_yticklabels([])
        ax.set_zticklabels([])

        plt.tight_layout()
        # plt.show()

        wfp = f'res/AFLW-2000-3D/{osp.basename(img_fp)}'
        plt.savefig(wfp, dpi=200) 
開發者ID:cleardusk,項目名稱:3DDFA,代碼行數:63,代碼來源:visualize.py

示例13: plot_ys

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def plot_ys(*ys, labels=None):
    """Plot time series

    Parameters
    ----------
    ys : pd.Series
        One or more time series
    labels : list, optional (default=None)
        Names of time series displayed in figure legend

    Returns
    -------
    fig : plt.Figure
    ax : plt.Axis
    """
    import matplotlib.pyplot as plt

    if labels is not None:
        if len(ys) != len(labels):
            raise ValueError("There must be one label for each time series, "
                             "but found inconsistent numbers of series and "
                             "labels.")
        labels_ = labels
    else:
        labels_ = ["" for _ in range(len(ys))]

    fig, ax = plt.subplots(1, figsize=plt.figaspect(.25))

    for y, label in zip(ys, labels_):
        check_y(y)

        # scatter if only a few points are available
        continuous_index = np.arange(y.index.min(), y.index.max() + 1)
        if len(y) < 3 or not np.array_equal(y.index.values, continuous_index):
            ax.scatter(y.index.values, y.values, label=label)
        # otherwise use line plot
        else:
            ax.plot(y.index.values, y.values, label=label)

    if labels is not None:
        plt.legend()

    return fig, ax 
開發者ID:alan-turing-institute,項目名稱:sktime,代碼行數:45,代碼來源:forecasting.py

示例14: plot_2d

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def plot_2d(self, pose_2d_x, pose_2d_y, kpts_v, BLOCK=True, ax=None):
        if ax is None:
            fig = plt.figure(figsize=plt.figaspect(1.))
            plt.clf()
            self.ax = fig.add_subplot(1, 1, 1)
        else:
            self.ax = ax
        self._plot_skeleton(kpts_v, pose_2d_x, pose_2d_y)

        if self.ax_2d_lims:
            self.ax.set_xlim(self.x_start_2d, self.x_end_2d)
            self.ax.set_ylim(self.y_start_2d, self.y_end_2d)
        else:
            # uses the keypoint visibility flags to select the max and min
            # across the x and y dimensions for setting the plot axis limits
            max_x = np.max(pose_2d_x[kpts_v.astype(np.bool)])
            min_x = np.min(pose_2d_x[kpts_v.astype(np.bool)])
            max_y = np.max(pose_2d_y[kpts_v.astype(np.bool)])
            min_y = np.min(pose_2d_y[kpts_v.astype(np.bool)])

            w  = max_x - min_x
            h  = max_y - min_y

            cx = int(min_x + w/2.)
            cy = int(min_y + h/2.)

            ENLARGE = 0.
            bbox = [cx - (w*(1+ENLARGE))/2.,
                    cy - (h*(1+ENLARGE))/2., w*(1+ENLARGE), h*(1+ENLARGE)]
            slack = int(bbox[2]/2.) if w > h else int(bbox[3]/2.)

            x_start = cx - slack
            x_end   = cx + slack
            y_start = cy - slack
            y_end   = cy + slack
            self.ax.set_xlim(x_start, x_end)
            self.ax.set_ylim(y_start, y_end)

        self.ax.invert_yaxis()
        # self.ax.set_xlabel("x")
        # self.ax.set_ylabel("y")

        if ax is None:
            if BLOCK:
                plt.show()
                #plt.close()
            else:
                plt.draw()
                plt.pause(0.01) 
開發者ID:matteorr,項目名稱:rel_3d_pose,代碼行數:51,代碼來源:pose_plotter.py

示例15: plot_3d

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figaspect [as 別名]
def plot_3d(self, pose_3d_x, pose_3d_y, pose_3d_z, kpts_v, BLOCK=True, ax=None):
        if ax is None:
            fig = plt.figure(figsize=plt.figaspect(1.))
            plt.clf()
            self.ax = fig.add_subplot(1, 1, 1, projection='3d')
        else:
            self.ax = ax

        self._plot_skeleton(kpts_v, pose_3d_x, pose_3d_y, pose_3d_z)

        if self.ax_3d_lims:
            self.ax.set_xlim(self.x_start_3d, self.x_end_3d)
            self.ax.set_ylim(self.z_start_3d, self.z_end_3d)
            self.ax.set_zlim(self.y_start_3d, self.y_end_3d)
        else:
            max_range = np.array([pose_3d_x.max()-pose_3d_x.min(),
                          pose_3d_y.max()-pose_3d_y.min(),
                          pose_3d_z.max()-pose_3d_z.min()]).max() / 2.0
            mid_x = (pose_3d_x.max()+pose_3d_x.min()) * 0.5
            mid_y = (pose_3d_y.max()+pose_3d_y.min()) * 0.5
            mid_z = (pose_3d_z.max()+pose_3d_z.min()) * 0.5

            x_start = mid_x - max_range
            x_end   = mid_x + max_range
            y_start = mid_y - max_range
            y_end   = mid_y + max_range
            z_start = mid_z - max_range
            z_end   = mid_z + max_range
            self.ax.set_xlim(x_start, x_end)
            self.ax.set_ylim(z_start, z_end)
            self.ax.set_zlim(y_start, y_end)

        self.ax.invert_zaxis()
        # self.ax.set_xlabel("x")
        # self.ax.set_ylabel("z")
        # self.ax.set_zlabel("y")

        if ax is None:
            if BLOCK:
                plt.show()
                #plt.close()
            else:
                plt.draw()
                plt.pause(0.01) 
開發者ID:matteorr,項目名稱:rel_3d_pose,代碼行數:46,代碼來源:pose_plotter.py


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