Exemplo n.º 1
0
    def heatmap(
        cls,
        x: np.ndarray,
        y: np.ndarray,
        c: np.ndarray = None,  # the variable to heatmap, if None XY occupancy
        ax: plt.Axes = None,
        colorbar: bool = False,
        gridsize: int = 30,
        **kwargs,
    ):
        ax = ax or plt.gca()

        if isinstance(x, pd.Series):
            raise ValueError("Heatmapt plotting cannot accept a pandas Series")
        else:
            H = ax.hexbin(x, y, c, gridsize=gridsize, **kwargs)

            if colorbar:
                divider = make_axes_locatable(ax)
                cax = divider.append_axes("bottom", size="5%", pad=0.05)

                ax.figure.colorbar(H, cax=cax, orientation="horizontal")