mpl.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:pwtools 作者: elcorto 项目源码 文件源码
def plotlines3d(ax3d, x,y,z, *args, **kwargs):
    """Plot x-z curves stacked along y.

    Parameters
    ----------
    ax3d : Axes3D instance
    x : nd array
        1d (x-axis) or 2d (x-axes are the columns)
    y : 1d array        
    z : nd array with "y"-values
        1d : the same curve will be plotted len(y) times against x (1d) or
             x[:,i] (2d) 
        2d : each column z[:,i] will be plotted against x (1d) or each x[:,i]
             (2d)
    *args, **kwargs : additional args and keywords args passed to ax3d.plot()

    Returns
    -------
    ax3d

    Examples
    --------
    >>> x = linspace(0,5,100)
    >>> y = arange(1.0,5) # len(y) = 4
    >>> z = np.repeat(sin(x)[:,None], 4, axis=1)/y # make 2d 
    >>> fig,ax = fig_ax3d()
    >>> plotlines3d(ax, x, y, z)
    >>> show()
    """
    assert y.ndim == 1
    if z.ndim == 1:
        zz = np.repeat(z[:,None], len(y), axis=1)
    else:
        zz = z
    if x.ndim == 1:
        xx = np.repeat(x[:,None], zz.shape[1], axis=1)
    else:
        xx = x
    assert xx.shape == zz.shape
    assert len(y) == xx.shape[1] == zz.shape[1]
    for j in range(xx.shape[1]):
        ax3d.plot(xx[:,j], np.ones(xx.shape[0])*y[j], z[:,j], *args, **kwargs)
    return ax3d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号