matplotlib.py 文件源码

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

项目:physt 作者: janpipek 项目源码 文件源码
def bar3d(h2, ax, **kwargs):
    """Plot of 2D histograms as 3D boxes.

    Parameters
    ----------
    h2 : Histogram2D

    Returns
    -------
    plt.Axes
    """
    density = kwargs.pop("density", False)
    data = get_data(h2, cumulative=False, flatten=True, density=density)
    # transformed = transform_data(data, kwargs)

    if "cmap" in kwargs:
        cmap = _get_cmap(kwargs)
        _, cmap_data = _get_cmap_data(data, kwargs)
        colors = cmap(cmap_data)
    else:
        colors = kwargs.pop("color", "blue")

    xpos, ypos = (arr.flatten() for arr in h2.get_bin_centers())
    zpos = np.zeros_like(ypos)
    dx, dy = (arr.flatten() for arr in h2.get_bin_widths())

    _add_labels(ax, h2, kwargs)
    ax.bar3d(xpos, ypos, zpos, dx, dy, data, color=colors, **kwargs)
    ax.set_zlabel("density" if density else "frequency")

    return ax
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号