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


Python Ellipse.set_transform方法代码示例

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


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

示例1: create_artists

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_transform [as 别名]
 def create_artists(self, legend, orig_handle,
                    xdescent, ydescent, width, height, fontsize, trans):
     center = 0.5 * width - 0.5 * xdescent, 0.5 * height - 0.5 * ydescent
     p = Ellipse(xy=center, width=height + xdescent,
                 height=height + ydescent, fill=False)
     self.update_prop(p, orig_handle, legend)
     p.set_transform(trans)
     return [p]
开发者ID:tvwenger,项目名称:casa_pipeline,代码行数:10,代码来源:plotreg.py

示例2: confidence_ellipse

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_transform [as 别名]
def confidence_ellipse(x, y, ax, n_std=3.0, facecolor='none', **kwargs):
    """
    Create a plot of the covariance confidence ellipse of `x` and `y`

    Parameters
    ----------
    x, y : array_like, shape (n, )
        Input data.

    ax : matplotlib.axes.Axes
        The axes object to draw the ellipse into.

    n_std : float
        The number of standard deviations to determine the ellipse's radiuses.

    Returns
    -------
    matplotlib.patches.Ellipse

    Other parameters
    ----------------
    kwargs : `~matplotlib.patches.Patch` properties
    """
    if x.size != y.size:
        raise ValueError("x and y must be the same size")

    cov = np.cov(x, y)
    pearson = cov[0, 1]/np.sqrt(cov[0, 0] * cov[1, 1])
    # Using a special case to obtain the eigenvalues of this
    # two-dimensionl dataset.
    ell_radius_x = np.sqrt(1 + pearson)
    ell_radius_y = np.sqrt(1 - pearson)
    ellipse = Ellipse((0, 0),
        width=ell_radius_x * 2,
        height=ell_radius_y * 2,
        facecolor=facecolor,
        **kwargs)

    # Calculating the stdandard deviation of x from
    # the squareroot of the variance and multiplying
    # with the given number of standard deviations.
    scale_x = np.sqrt(cov[0, 0]) * n_std
    mean_x = np.mean(x)

    # calculating the stdandard deviation of y ...
    scale_y = np.sqrt(cov[1, 1]) * n_std
    mean_y = np.mean(y)

    transf = transforms.Affine2D() \
        .rotate_deg(45) \
        .scale(scale_x, scale_y) \
        .translate(mean_x, mean_y)

    ellipse.set_transform(transf + ax.transData)
    return ax.add_patch(ellipse)
开发者ID:QuLogic,项目名称:matplotlib,代码行数:57,代码来源:confidence_ellipse.py

示例3: plot_network_activity

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_transform [as 别名]
  def plot_network_activity(self, stimulus_input=None):
    """Plot the activity of the whole network on a specific stimulus.

    Shows activations of both layers
    """

    if stimulus_input is None:
      stimulus_input = (0, ) * self.R

    # Compute activity of network on the stimulus
    self.get_network_response(stimulus_input=stimulus_input)

    # Do a subplot, second layer on top, first layer on bottom
    plt.figure()
    ax_layertwo = plt.subplot(2, 1, 1)
    ax_layerone = plt.subplot(2, 1, 2)

    # Plot the level two activation, use a bar, easier to read
    ax_layertwo.bar(
        np.arange(self.M_layer_two), self.current_layer_two_response)

    # Plot the activation of the level one subnetwork (and of the individual responses at level two)
    M_sqrt = int(self.M_layer_one**0.5)

    # Level one
    im = ax_layerone.imshow(
        self.current_layer_one_response[:int(M_sqrt**2)].reshape(
            M_sqrt, M_sqrt).T,
        origin='lower',
        aspect='equal',
        cmap='RdBu_r',
        interpolation='nearest')
    im.set_extent((-np.pi, np.pi, -np.pi, np.pi))
    ax_layerone.set_xticks((-np.pi, -np.pi / 2, 0, np.pi / 2., np.pi))
    ax_layerone.set_xticklabels((r'$-\pi$', r'$-\frac{\pi}{2}$', r'$0$',
                                 r'$\frac{\pi}{2}$', r'$\pi$'))
    ax_layerone.set_yticks((-np.pi, -np.pi / 2, 0, np.pi / 2., np.pi))
    ax_layerone.set_yticklabels((r'$-\pi$', r'$-\frac{\pi}{2}$', r'$0$',
                                 r'$\frac{\pi}{2}$', r'$\pi$'))

    e = Ellipse(xy=stimulus_input, width=0.4, height=0.4)

    ax_layerone.add_artist(e)
    e.set_clip_box(ax_layerone.bbox)
    e.set_alpha(0.5)
    e.set_facecolor('white')
    e.set_transform(ax_layerone.transData)

    plt.show()
开发者ID:Azhag,项目名称:Bayesian-visual-working-memory,代码行数:51,代码来源:hierarchicalrandomnetwork.py


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