示例#1
0
    def test_reset_orig(self):

        # Changes to the rc parameters make this test hard to manage
        # on older versions of matplotlib, so we'll skip it
        if LooseVersion(mpl.__version__) < LooseVersion("1.3"):
            raise nose.SkipTest

        rcmod.reset_orig()
        self.assert_rc_params(mpl.rcParamsOrig)
        rcmod.set()
示例#2
0
    def test_set_serif_font(self):

        rcmod.set(font="serif")

        _, ax = plt.subplots()
        ax.set_xlabel("foo")

        nt.assert_in(ax.xaxis.label.get_fontname(),
                     mpl.rcParams["font.serif"])

        rcmod.set()
        plt.close("all")
示例#3
0
def test_ticklabels_overlap():

    rcmod.set()
    f, ax = plt.subplots(figsize=(2, 2))
    f.tight_layout()  # This gets the Agg renderer working

    assert not utils.axis_ticklabels_overlap(ax.get_xticklabels())

    big_strings = "abcdefgh", "ijklmnop"
    ax.set_xlim(-.5, 1.5)
    ax.set_xticks([0, 1])
    ax.set_xticklabels(big_strings)

    assert utils.axis_ticklabels_overlap(ax.get_xticklabels())

    x, y = utils.axes_ticklabels_overlap(ax)
    assert x
    assert not y
示例#4
0
    def test_set_font(self):

        rcmod.set(font="Verdana")

        _, ax = plt.subplots()
        ax.set_xlabel("foo")

        try:
            self.assertEqual(ax.xaxis.label.get_fontname(),
                             "Verdana")
        except AssertionError:
            if has_verdana():
                raise
            else:
                raise unittest.skip("Verdana font is not present")
        finally:
            rcmod.set()
            plt.close("all")
示例#5
0
    def test_different_sans_serif(self):

        if LooseVersion(mpl.__version__) < LooseVersion("1.4"):
            raise nose.SkipTest

        rcmod.set()
        rcmod.set_style(rc={"font.sans-serif":
                            ["Verdana"]})

        _, ax = plt.subplots()
        ax.set_xlabel("foo")

        try:
            self.assertEqual(ax.xaxis.label.get_fontname(),
                             "Verdana")
        except AssertionError:
            if has_verdana():
                raise
            else:
                raise unittest.skip("Verdana font is not present")
        finally:
            rcmod.set()
            plt.close("all")
示例#6
0
    def test_set_rc(self):

        rcmod.set(rc={"lines.linewidth": 4})
        self.assertEqual(mpl.rcParams["lines.linewidth"], 4)
        rcmod.set()
示例#7
0
    def test_current_palette(self):

        pal = palettes.color_palette(["red", "blue", "green"], 3)
        rcmod.set_palette(pal, 3)
        self.assertEqual(pal, mpl.rcParams["axes.color_cycle"])
        rcmod.set()