Esempio n. 1
0
 def set_my_locators_and_formatters(self, axis):
     # choose the default locator and additional parameters
     if isinstance(axis, matplotlib.axis.XAxis):
         axis.set_major_locator(MaxNLocator())
     elif isinstance(axis, matplotlib.axis.YAxis):
         axis.set_major_locator(MaxNLocator())
     # copy&paste from the original method
     axis.set_major_formatter(ScalarFormatter())
     axis.set_minor_locator(NullLocator())
     axis.set_minor_formatter(NullFormatter())
Esempio n. 2
0
    def scatter_simple(self, count_x: pd.Series, count_y: pd.Series, log_norm=False, **kwargs) -> plt.Axes:
        """Creates a simple scatter plot of counts.

        Args:
            count_x: A pandas dataframe/series of counts per feature (X axis)
            count_y: A pandas dataframe/series of counts per feature (Y axis)
            log_norm: Plot on log scale rather than linear scale
            kwargs: Additional keyword arguments to pass to pyplot.Axes.scatter()

        Returns:
            ax: A simple scatter plot of counts
        """

        # Retrieve axis and styles for this plot type
        fig, ax = self.reuse_subplot("scatter")
        ax: plt.Axes

        # log2 normalize data if requested
        if log_norm:
            # Set log2 scale
            ax.set_xscale('log', base=2)
            ax.set_yscale('log', base=2)

            # Unset default formatters
            for axis in [ax.xaxis, ax.yaxis]:
                axis.set_major_formatter(tix.LogFormatterExponent(base=2))
                axis.set_minor_formatter(tix.NullFormatter())

            ax.scatter(count_x, count_y, edgecolor='none', **kwargs)

            # Draw y = x, x +/- 1 lines (log2 scale) using point pairs for the 3 lines
            for p1,p2 in [((1, 2), (2, 4)), ((1, 1), (2, 2)), ((1, 0.5), (2, 1))]:
                ax.axline(p1, p2, color='#CCCCCC', label='_nolegend_')
        else:
            # Set linear scale
            ax.set_xscale('linear')
            ax.set_yscale('linear')

            # Set up axis ticks and labels
            for axis in [ax.xaxis, ax.yaxis]:
                axis.set_major_locator(tix.MaxNLocator(6))
                axis.set_major_formatter(tix.ScalarFormatter())

            ax.scatter(count_x, count_y, **kwargs)

            # Draw y = x, x +/- 1 lines using point pairs for the 3 lines
            for p1,p2 in [((0, 1), (1, 2)), ((0, 0), (1, 1)), ((0,-1), (1, 0))]:
                ax.axline(p1, p2, color='#CCCCCC', label='_nolegend_')

        return ax
Esempio n. 3
0
 def set_default_locators_and_formatters(self, axis):
     axis.set_major_locator(self.AddressSpaceTickLocator(self))
     axis.set_major_formatter(self.HexFormatter())
     axis.set_minor_formatter(self.HexFormatter())