Python matplotlib.pyplot 模块,GridSpec() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用matplotlib.pyplot.GridSpec()

项目:yellowbrick    作者:DistrictDataLabs    | 项目源码 | 文件源码
def draw(self, X, y, **kwargs):
        """
        Sets up the layout for the joint plot draw calls ``draw_joint`` and
        ``draw_xy`` to render the visualizations.
        """

        fig = plt.figure(figsize=(self.size, self.size))
        gs = plt.GridSpec(self.ratio + 1, self.ratio + 1)

        #Set up the 3 axes objects
        joint_ax = fig.add_subplot(gs[1:, :-1])
        x_ax = fig.add_subplot(gs[0, :-1], sharex=joint_ax)
        y_ax = fig.add_subplot(gs[1:, -1], sharey=joint_ax)

        fig.tight_layout()
        fig.subplots_adjust(hspace=self.space, wspace=self.space)

        self.fig = fig
        self.joint_ax = joint_ax
        self.x_ax = x_ax
        self.y_ax = y_ax

        self.draw_joint(X, y, **kwargs)
        self.draw_xy(X, y, **kwargs)
项目:Waskom_PNAS_2017    作者:WagnerLabPapers    | 项目源码 | 文件源码
def setup_figure():

    f = plt.figure(figsize=(6, 2.15))

    brain_gs = plt.GridSpec(2, 2, .03, .18, .52, .99, .05, .05)
    brain_axes = [f.add_subplot(gs) for gs in brain_gs]
    brain_axes = np.reshape(brain_axes, (2, 2))

    hist_gs = plt.GridSpec(2, 1, .53, .20, .65, .975)
    hist_axes = [f.add_subplot(gs) for gs in hist_gs]

    cmap_gs = plt.GridSpec(1, 2, .05, .07, .50, .14, .05, .05)
    cmap_axes = [f.add_subplot(gs) for gs in cmap_gs]

    clust_gs = plt.GridSpec(1, 1, .75, .20, .98, .98)
    clust_ax = f.add_subplot(clust_gs[0])

    f.text(.003, .92, "A", size=12)
    f.text(.68, .92, "B", size=12)

    return f, brain_axes, hist_axes, cmap_axes, clust_ax
项目:paladin-plugins    作者:twestbrookunh    | 项目源码 | 文件源码
def setupGrid(passRows, passCols):
    plugins.plotting.plotGrid = plot.GridSpec(passRows, passCols)

# Change current grid location
项目:Waskom_PNAS_2017    作者:WagnerLabPapers    | 项目源码 | 文件源码
def setup_figure():

    f = plt.figure(figsize=(7, 2.8))

    brain_gs = plt.GridSpec(3, 4, .13, .13, .87, .99, .05, .05)
    brain_axes = [f.add_subplot(gs) for gs in brain_gs]
    brain_axes = np.vstack(np.array_split(brain_axes, 6))

    hist_gs = plt.GridSpec(3, 2, .01, .15, .99, .99, 7, .08)
    hist_axes = [f.add_subplot(gs) for gs in hist_gs]

    cbar_ax = f.add_axes([.35, .07, .3, .04])

    return f, brain_axes, hist_axes, cbar_ax
项目:Waskom_PNAS_2017    作者:WagnerLabPapers    | 项目源码 | 文件源码
def setup_figure():

    f = plt.figure(figsize=(7, 4.65))

    dots_grid = plt.GridSpec(2, 7, .08, .45, .98, .94, .15, .15)
    dots_axes = [f.add_subplot(spec) for spec in dots_grid]

    sticks_grid = plt.GridSpec(1, 6, .12, .09, .92, .34, .15, .1)
    sticks_axes = [f.add_subplot(spec) for spec in sticks_grid]

    return f, dots_axes, sticks_axes
项目:Waskom_PNAS_2017    作者:WagnerLabPapers    | 项目源码 | 文件源码
def setup_figure():

    f = plt.figure(figsize=(7, 6))

    dots_grid = plt.GridSpec(2, 7, .1, .56, .98, .94, .1, .15)
    dots_axes = [f.add_subplot(spec) for spec in dots_grid]

    sticks_grid = plt.GridSpec(1, 6, .18, .31, .92, .48, .1, .1)
    sticks_axes = [f.add_subplot(spec) for spec in sticks_grid]

    rest_grid = plt.GridSpec(1, 6, .18, .07, .92, .24, .1, .1)
    rest_axes = [f.add_subplot(spec) for spec in rest_grid]

    return f, dots_axes, sticks_axes, rest_axes
项目:Waskom_PNAS_2017    作者:WagnerLabPapers    | 项目源码 | 文件源码
def setup_figure():

    f = plt.figure(figsize=(7, 6.56))

    brain_gs = plt.GridSpec(7, 4, .13, .10, .87, .99, .05, .05)
    brain_axes = [f.add_subplot(gs) for gs in brain_gs]
    brain_axes = np.vstack(np.array_split(brain_axes, 14))

    hist_gs = plt.GridSpec(7, 2, .01, .11, .99, .99, 7, .08)
    hist_axes = [f.add_subplot(gs) for gs in hist_gs]

    cbar_ax = f.add_axes([.35, .06, .3, .02])

    return f, brain_axes, hist_axes, cbar_ax
项目:Waskom_PNAS_2017    作者:WagnerLabPapers    | 项目源码 | 文件源码
def setup_figure():

    f = plt.figure(figsize=(7, 4.5))

    dots_grid = plt.GridSpec(2, 7, .02, .51, .98, .94, 0, 0)
    dots_axes = [f.add_subplot(spec) for spec in dots_grid]

    sticks_grid = plt.GridSpec(1, 6, .09, .26, .91, .47, 0, 0)
    sticks_axes = [f.add_subplot(spec) for spec in sticks_grid]

    rest_grid = plt.GridSpec(1, 6, .09, .01, .91, .22, 0, 0)
    rest_axes = [f.add_subplot(spec) for spec in rest_grid]

    return f, dots_axes, sticks_axes, rest_axes
项目:pastas    作者:pastas    | 项目源码 | 文件源码
def diagnostics(self, tmin=None, tmax=None, show=True):
        innovations = self.ml.innovations(tmin, tmax)

        fig = self._get_figure()
        gs = plt.GridSpec(2, 3, wspace=0.2)

        plt.subplot(gs[0, :2])
        plt.title('Autocorrelation')
        # plt.axhline(0.2, '--')
        r = ps.stats.acf(innovations)
        plt.stem(r)

        plt.subplot(gs[1, :2])
        plt.title('Partial Autocorrelation')
        # plt.axhline(0.2, '--')
        # plt.stem(self.ml.stats.pacf())

        plt.subplot(gs[0, 2])
        innovations.hist(bins=20)

        plt.subplot(gs[1, 2])
        probplot(innovations, plot=plt)

        if show:
            plt.show()

        return fig.axes