Пример #1
0
 def set_params(self, **kwargs):
     """Set parameters within this locator."""
     MaxNLocator.set_params(self, **kwargs)
     if 'dms' in kwargs:
         self._dms = kwargs['dms']
Пример #2
0
 def set_params(self, **kwargs):
     """Set parameters within this locator."""
     if 'dms' in kwargs:
         self._dms = kwargs.pop('dms')
     MaxNLocator.set_params(self, **kwargs)
Пример #3
0
    def _format(
        self,
        locator=None,
        minor_locator=None,
        grid={
            "which": "major",
            "axis": "y",
            "color": "black",
            "linestyle": "--",
            "linewidth": 0.5,
            "alpha": 0.5,
        },
        minor_grid={
            "which": "minor",
            "axis": "y",
            "color": "black",
            "linestyle": "--",
            "linewidth": 0.5,
            "alpha": 0.25,
        },
        ymargin=0.1,
        show_xaxis=False,
        show_yaxis=True,
        **kwargs,
    ):
        """Format Axes helper function

        Args:
            (matplotlib.ticker) locator:
                Object which determines the major ticks on the y-axis

            (matplotlib.ticker) minor_locator:
                Object which determines the minor ticks on the y-axis

            (dict) grid:
                Grid kwargs which determine the appearance of the major grid

            (dict) minor_grid:
                Grid kwargs which determine the appearance of the minor grid

            (float) ymargin:
                Value to be passed to matplotlib.axes.Axes.margin for padding

            (bool) show_xaxis:
                Shows x-axis and ticks if True, otherwise hidden

            (bool) show_yaxis:
                Shows y-axis and ticks if True, otherwise hidden
        """
        label = LABELS[self.col_name] if self.col_name in LABELS else self.col_name

        if locator is None:
            locator = MaxNLocator(nbins=4, integer=True, min_n_ticks=3)

        if self.col_name == "rotor_frequency":
            locator.set_params(integer=False, steps=[1.5, 5, 7])

        self.get_xaxis().set_visible(show_xaxis)
        self.set_xlim(0, self.xmax)

        self.get_yaxis().set_visible(show_yaxis)
        self.set_ylabel(label, fontsize=DEFAULT_FONT_SIZE)
        self.get_yaxis().set_major_locator(locator)
        if minor_locator is not None:
            self.get_yaxis().set_minor_locator(minor_locator)
            self.grid(**minor_grid)

        self.spines["top"].set_visible(show_xaxis)
        self.spines["right"].set_visible(show_xaxis)
        self.spines["bottom"].set_visible(show_xaxis)

        self.grid(**grid)
        self.margins(y=ymargin)
        self.tick_params(axis="both", labelsize=DEFAULT_FONT_SIZE)