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)
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)
def test_columns(self): width = self.width / 2 height = GOLDEN_RATIO * width assert lp.figure_size(n_columns=2) == (width, height)
def test_height_no_ratio(self): assert lp.figure_size(height=5) == (self.width, 5)
def test_ratio_height(self): dimensions = (self.width, self.width) assert lp.figure_size(ratio=1, height=5) == dimensions
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)
def test_defaults(self): height = GOLDEN_RATIO * self.width assert lp.figure_size() == (self.width, height)
# 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: