Beispiel #1
0
    def __init__(self, ystack_ratios, xratios=1, figsize=(10, 10),
                 startside='left', alternate_sides=True,
                 onespine_forboth=False, **kwargs):
        """
        Initialize X_Grid

        Parameters
        ----------
        ystack_ratiosratios : int or list of ints
            The relative sizes of the rows.  Not directly comparable
            to ``xratios``
        xratios : int or list of ints
            Default 1. The relative sizes of the main axis column(s).
            Not directly comparable to ``ystack_ratios``
        figsize : tuple of ints or floats
            Default (10,10).  The figure dimensions in inches
        startside : string
            Default 'left'.  ['left'|'right'].  The side the topmost y axis
            will be on.
        alternate_sides : Boolean
            Default ``True``.  [True|False].
            Stacked axis spines alternate sides or are all on ``startside``.
        onespine_forboth : Boolean
            Default ``False``.  [True|False].  If the plot stack is only 1 row,
            then both main axis spines can be visible (``False``),
            or only the bottom spine (``True``).
        **kwargs
            Any plt.figure arguments.  Passed to Grid.__init__(),
            plt.figure()

        """

        # Initialize parent class
        # Last arg is True because mainax_x
        Grid.__init__(self, xratios, ystack_ratios, True, figsize, **kwargs)

        # Set initial x and y grid positions (top left)
        xpos = 0
        ypos = 0

        # Create axes row by row
        for rowspan in self.yratios:
            row = []

            for c, colspan in enumerate(self.xratios):
                sharex = None
                sharey = None

                # All axes in a row share y axis with first axis in row
                if xpos > 0:
                    sharey = row[0]

                # All axes in a column share x axis with first axis in column
                if ypos > 0:
                    sharex = self.axes[0][c]

                ax = plt.subplot2grid((self.gridrows, self.gridcols),
                                      (ypos, xpos), rowspan=rowspan,
                                      colspan=colspan, sharey=sharey,
                                      sharex=sharex)

                ax.patch.set_visible(False)

                row.append(ax)
                xpos += colspan

            self.axes.append(row)

            # Reset x position to left side, move to next y position
            xpos = 0
            ypos += rowspan

        self.set_dataside(startside, alternate_sides)
        self.set_stackposition(onespine_forboth)
Beispiel #2
0
    def __init__(
        self,
        xstack_ratios,
        yratios=1,
        figsize=(10, 10),
        startside="top",
        alternate_sides=True,
        onespine_forboth=False,
        **kwargs
    ):
        """
        Initialize Y_Grid

        Parameters
        ----------
        xstack_ratios : int or list of ints
            The relative sizes of the columns.  Not directly comparable
            to ``yratios``
        yratios : int or list of ints
            Default 1.  The relative sizes of the main axis row(s).
            Not directly comparable to ``xstack_ratios``
        figsize : tuple of ints or floats
            Default (10, 10).  The figure dimensions in inches
        startside : string
            Default 'top'.  ['top'|'bottom'].  The side the leftmost x axis
            will be on.
        alternate_sides : Boolean
            Default ``True``.  [True|False].
            Stacked axis spines alternate sides or are all on ``startside``.
        onespine_forboth : Boolean
            Default ``False``.  [True|False].  If the plot stack is only 1
            column, then both main axis spines can be visible (``False``),
            or only the left spine is visible (``True``).
        **kwargs
            Any plt.figure arguments.  Passed to Grid.__init__(),
            plt.figure().

        """

        # Initialize parent class
        # Last arg is False because mainax_x
        Grid.__init__(self, xstack_ratios, yratios, False, figsize, **kwargs)

        # Set initial x and y grid positions (top left)
        xpos = 0
        ypos = 0

        # Create axes column by column
        for colspan in self.xratios:
            col = []

            for r, rowspan in enumerate(self.yratios):
                sharex = None
                sharey = None

                # All axes in column share x axis with first in column
                if ypos > 0:
                    sharex = col[0]

                # All axes in row share y axis with first in row
                if xpos > 0:
                    sharey = self.axes[0][r]

                ax = plt.subplot2grid(
                    (self.gridrows, self.gridcols),
                    (ypos, xpos),
                    rowspan=rowspan,
                    colspan=colspan,
                    sharex=sharex,
                    sharey=sharey,
                )

                ax.patch.set_visible(False)

                col.append(ax)
                ypos += rowspan

            self.axes.append(col)

            # Reset y position to top, move to next x position
            ypos = 0
            xpos += colspan

        self.set_dataside(startside, alternate_sides)
        self.set_stackposition(onespine_forboth)