예제 #1
0
    def test_default_size_is_figure_size(self):
        default_size = lp.figure_size()

        with patch('matplotlib.figure.Figure.set_size_inches') as mock_set, \
                patch('latexipy._latexipy.save_figure'):
            with lp.figure('filename'):
                pass

            mock_set.assert_called_once_with(*default_size)
예제 #2
0
 def test_height_too_high(self):
     with pytest.warns(UserWarning):
         height = MAX_HEIGHT_INCH + 1
         assert lp.figure_size(height=height) == (self.width,
                                                  MAX_HEIGHT_INCH)
예제 #3
0
 def test_columns(self):
     width = self.width / 2
     height = GOLDEN_RATIO * width
     assert lp.figure_size(n_columns=2) == (width, height)
예제 #4
0
 def test_height_no_ratio(self):
     assert lp.figure_size(height=5) == (self.width, 5)
예제 #5
0
 def test_ratio_height(self):
     dimensions = (self.width, self.width)
     assert lp.figure_size(ratio=1, height=5) == dimensions
예제 #6
0
 def test_ratio_no_height(self):
     assert lp.figure_size(ratio=1) == (self.width, self.width)
     assert lp.figure_size(ratio=0.5) == (self.width, self.width / 2)
예제 #7
0
 def test_defaults(self):
     height = GOLDEN_RATIO * self.width
     assert lp.figure_size() == (self.width, height)
예제 #8
0
    # If you are repeating arguments, you might want to register a partial.
    figure = partial(lp.figure, directory=DIRECTORY)

    # You can generate figures without calling lp.latexify().
    generate_figures('_no_latex', figure)

    # latexify chooses values that go well with publications.
    lp.latexify()
    generate_figures('_with_latex', figure)

    # You can use the partial function just as you would the original.
    with figure('sincos_defaults'):
        plot_sin_and_cos()

    # You can change the size. 0.45\textwidth is useful when using two columns.
    with figure('sincos_small', size=lp.figure_size(0.45)):
        plot_sin_and_cos()

    # A ratio of 1 is great for squares.
    with figure('sincos_square', size=lp.figure_size(ratio=1)):
        plot_sin_and_cos()

    # And we can have a high figure if, for instance, stacking subplots.
    with figure('sincos_tall', size=lp.figure_size(0.6, ratio=2)):
        plot_sin_and_cos()

    # It is equivalent to the original function with the right arguments.
    with lp.figure('sincos_defaults_no_partial', directory=DIRECTORY):
        plot_sin_and_cos()

    # You can temporarily change parameters. To increase font size: