Example #1
0
    def test_kde_missing_vals(self):
        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        s = Series(np.random.uniform(size=50))
        s[0] = np.nan
        axes = _check_plot_works(s.plot.kde)

        # gh-14821: check if the values have any missing values
        assert any(~np.isnan(axes.lines[0].get_xdata()))
Example #2
0
 def test_kde_missing_vals(self):
     tm._skip_if_no_scipy()
     _skip_if_no_scipy_gaussian_kde()
     s = Series(np.random.uniform(size=50))
     s[0] = np.nan
     axes = _check_plot_works(s.plot.kde)
     # check if the values have any missing values
     # GH14821
     self.assertTrue(any(~np.isnan(axes.lines[0].get_xdata())), msg="Missing Values not dropped")
Example #3
0
    def test_kde_missing_vals(self):
        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        s = Series(np.random.uniform(size=50))
        s[0] = np.nan
        axes = _check_plot_works(s.plot.kde)

        # gh-14821: check if the values have any missing values
        assert any(~np.isnan(axes.lines[0].get_xdata()))
Example #4
0
 def test_kde_missing_vals(self):
     tm._skip_if_no_scipy()
     _skip_if_no_scipy_gaussian_kde()
     s = Series(np.random.uniform(size=50))
     s[0] = np.nan
     axes = _check_plot_works(s.plot.kde)
     # check if the values have any missing values
     # GH14821
     self.assertTrue(any(~np.isnan(axes.lines[0].get_xdata())),
                     msg='Missing Values not dropped')
Example #5
0
    def test_kde_kwargs(self):
        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        from numpy import linspace

        _check_plot_works(self.ts.plot.kde, bw_method=0.5, ind=linspace(-100, 100, 20))
        _check_plot_works(self.ts.plot.density, bw_method=0.5, ind=linspace(-100, 100, 20))
        ax = self.ts.plot.kde(logy=True, bw_method=0.5, ind=linspace(-100, 100, 20))
        self._check_ax_scales(ax, yaxis="log")
        self._check_text_labels(ax.yaxis.get_label(), "Density")
Example #6
0
    def test_secondary_kde(self):
        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()

        ser = Series(np.random.randn(10))
        fig, ax = self.plt.subplots()
        ax = ser.plot(secondary_y=True, kind='density', ax=ax)
        assert hasattr(ax, 'left_ax')
        assert not hasattr(ax, 'right_ax')
        axes = fig.get_axes()
        assert axes[1].get_yaxis().get_ticks_position() == 'right'
    def test_kde_missing_vals(self):
        _skip_if_no_scipy_gaussian_kde()
        if not self.mpl_ge_1_5_0:
            pytest.skip("mpl is not supported")

        s = Series(np.random.uniform(size=50))
        s[0] = np.nan
        axes = _check_plot_works(s.plot.kde)

        # gh-14821: check if the values have any missing values
        assert any(~np.isnan(axes.lines[0].get_xdata()))
Example #8
0
    def test_kde_missing_vals(self):
        _skip_if_no_scipy_gaussian_kde()
        if not self.mpl_ge_1_5_0:
            pytest.skip("mpl is not supported")

        s = Series(np.random.uniform(size=50))
        s[0] = np.nan
        axes = _check_plot_works(s.plot.kde)

        # gh-14821: check if the values have any missing values
        assert any(~np.isnan(axes.lines[0].get_xdata()))
Example #9
0
 def test_kde_kwargs(self):
     tm._skip_if_no_scipy()
     _skip_if_no_scipy_gaussian_kde()
     from numpy import linspace
     _check_plot_works(self.ts.plot.kde, bw_method=.5,
                       ind=linspace(-100, 100, 20))
     _check_plot_works(self.ts.plot.density, bw_method=.5,
                       ind=linspace(-100, 100, 20))
     ax = self.ts.plot.kde(logy=True, bw_method=.5,
                           ind=linspace(-100, 100, 20))
     self._check_ax_scales(ax, yaxis='log')
     self._check_text_labels(ax.yaxis.get_label(), 'Density')
Example #10
0
    def test_secondary_kde(self):
        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()

        import matplotlib.pyplot as plt  # noqa
        ser = Series(np.random.randn(10))
        ax = ser.plot(secondary_y=True, kind='density')
        self.assertTrue(hasattr(ax, 'left_ax'))
        self.assertFalse(hasattr(ax, 'right_ax'))
        fig = ax.get_figure()
        axes = fig.get_axes()
        self.assertEqual(axes[1].get_yaxis().get_ticks_position(), 'right')
Example #11
0
    def test_secondary_kde(self):
        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()

        import matplotlib.pyplot as plt  # noqa
        ser = Series(np.random.randn(10))
        ax = ser.plot(secondary_y=True, kind='density')
        self.assertTrue(hasattr(ax, 'left_ax'))
        self.assertFalse(hasattr(ax, 'right_ax'))
        fig = ax.get_figure()
        axes = fig.get_axes()
        self.assertEqual(axes[1].get_yaxis().get_ticks_position(), 'right')
Example #12
0
    def test_hist_kde_color(self):
        ax = self.ts.plot.hist(logy=True, bins=10, color='b')
        self._check_ax_scales(ax, yaxis='log')
        self.assertEqual(len(ax.patches), 10)
        self._check_colors(ax.patches, facecolors=['b'] * 10)

        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        ax = self.ts.plot.kde(logy=True, color='r')
        self._check_ax_scales(ax, yaxis='log')
        lines = ax.get_lines()
        self.assertEqual(len(lines), 1)
        self._check_colors(lines, ['r'])
Example #13
0
    def test_hist_kde_color(self):
        ax = self.ts.plot.hist(logy=True, bins=10, color='b')
        self._check_ax_scales(ax, yaxis='log')
        self.assertEqual(len(ax.patches), 10)
        self._check_colors(ax.patches, facecolors=['b'] * 10)

        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        ax = self.ts.plot.kde(logy=True, color='r')
        self._check_ax_scales(ax, yaxis='log')
        lines = ax.get_lines()
        self.assertEqual(len(lines), 1)
        self._check_colors(lines, ['r'])
Example #14
0
    def test_hist_kde_color(self):
        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(logy=True, bins=10, color='b', ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        assert len(ax.patches) == 10
        self._check_colors(ax.patches, facecolors=['b'] * 10)

        _skip_if_no_scipy_gaussian_kde()
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, color='r', ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        lines = ax.get_lines()
        assert len(lines) == 1
        self._check_colors(lines, ['r'])
Example #15
0
    def test_hist_kde_color(self):
        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(logy=True, bins=10, color='b', ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        assert len(ax.patches) == 10
        self._check_colors(ax.patches, facecolors=['b'] * 10)

        _skip_if_no_scipy_gaussian_kde()
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, color='r', ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        lines = ax.get_lines()
        assert len(lines) == 1
        self._check_colors(lines, ['r'])
Example #16
0
    def test_kde_kwargs(self):
        _skip_if_no_scipy_gaussian_kde()

        sample_points = np.linspace(-100, 100, 20)
        _check_plot_works(self.ts.plot.kde, bw_method='scott', ind=20)
        _check_plot_works(self.ts.plot.kde, bw_method=None, ind=20)
        _check_plot_works(self.ts.plot.kde, bw_method=None, ind=np.int(20))
        _check_plot_works(self.ts.plot.kde, bw_method=.5, ind=sample_points)
        _check_plot_works(self.ts.plot.density, bw_method=.5,
                          ind=sample_points)
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, bw_method=.5, ind=sample_points,
                              ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        self._check_text_labels(ax.yaxis.get_label(), 'Density')
Example #17
0
    def test_kde_kwargs(self):
        _skip_if_no_scipy_gaussian_kde()

        sample_points = np.linspace(-100, 100, 20)
        _check_plot_works(self.ts.plot.kde, bw_method='scott', ind=20)
        _check_plot_works(self.ts.plot.kde, bw_method=None, ind=20)
        _check_plot_works(self.ts.plot.kde, bw_method=None, ind=np.int(20))
        _check_plot_works(self.ts.plot.kde, bw_method=.5, ind=sample_points)
        _check_plot_works(self.ts.plot.density, bw_method=.5,
                          ind=sample_points)
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, bw_method=.5, ind=sample_points,
                              ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        self._check_text_labels(ax.yaxis.get_label(), 'Density')
Example #18
0
    def test_kde_kwargs(self):
        _skip_if_no_scipy_gaussian_kde()
        if not self.mpl_ge_1_5_0:
            pytest.skip("mpl is not supported")

        from numpy import linspace
        _check_plot_works(self.ts.plot.kde, bw_method=.5,
                          ind=linspace(-100, 100, 20))
        _check_plot_works(self.ts.plot.density, bw_method=.5,
                          ind=linspace(-100, 100, 20))
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, bw_method=.5,
                              ind=linspace(-100, 100, 20), ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        self._check_text_labels(ax.yaxis.get_label(), 'Density')
Example #19
0
    def test_kde_kwargs(self):
        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        if not self.mpl_ge_1_5_0:
            pytest.skip("mpl is not supported")

        from numpy import linspace
        _check_plot_works(self.ts.plot.kde, bw_method=.5,
                          ind=linspace(-100, 100, 20))
        _check_plot_works(self.ts.plot.density, bw_method=.5,
                          ind=linspace(-100, 100, 20))
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, bw_method=.5,
                              ind=linspace(-100, 100, 20), ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        self._check_text_labels(ax.yaxis.get_label(), 'Density')
Example #20
0
    def test_hist_kde(self):
        ax = self.ts.plot.hist(logy=True)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        # ticks are values, thus ticklabels are blank
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))

        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        _check_plot_works(self.ts.plot.kde)
        _check_plot_works(self.ts.plot.density)
        ax = self.ts.plot.kde(logy=True)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))
Example #21
0
    def test_hist_kde(self):
        ax = self.ts.plot.hist(logy=True)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        # ticks are values, thus ticklabels are blank
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))

        tm._skip_if_no_scipy()
        _skip_if_no_scipy_gaussian_kde()
        _check_plot_works(self.ts.plot.kde)
        _check_plot_works(self.ts.plot.density)
        ax = self.ts.plot.kde(logy=True)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))
Example #22
0
    def test_hist_kde(self):
        if not self.mpl_ge_1_5_0:
            pytest.skip("mpl is not supported")

        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(logy=True, ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        # ticks are values, thus ticklabels are blank
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))

        _skip_if_no_scipy_gaussian_kde()
        _check_plot_works(self.ts.plot.kde)
        _check_plot_works(self.ts.plot.density)
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))
    def test_hist_kde(self):
        if not self.mpl_ge_1_5_0:
            pytest.skip("mpl is not supported")

        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(logy=True, ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        # ticks are values, thus ticklabels are blank
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))

        _skip_if_no_scipy_gaussian_kde()
        _check_plot_works(self.ts.plot.kde)
        _check_plot_works(self.ts.plot.density)
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, ax=ax)
        self._check_ax_scales(ax, yaxis='log')
        xlabels = ax.get_xticklabels()
        self._check_text_labels(xlabels, [''] * len(xlabels))
        ylabels = ax.get_yticklabels()
        self._check_text_labels(ylabels, [''] * len(ylabels))
Example #24
0
 def test_kde_missing_vals(self):
     tm._skip_if_no_scipy()
     _skip_if_no_scipy_gaussian_kde()
     s = Series(np.random.uniform(size=50))
     s[0] = np.nan
     _check_plot_works(s.plot.kde)
Example #25
0
 def test_kde_missing_vals(self):
     tm._skip_if_no_scipy()
     _skip_if_no_scipy_gaussian_kde()
     s = Series(np.random.uniform(size=50))
     s[0] = np.nan
     _check_plot_works(s.plot.kde)