def test_scaled_figure_size2(): apply_style() fig = create_figure(width='2x', height='0.25x') assert fig.get_figwidth() == approx(2 * _default_width, 0.01) assert fig.get_figheight() == approx(0.25 * _default_height, 0.01)
def test_default_figure_size(): apply_style() fig = create_figure() assert fig.get_figwidth() == _default_width assert fig.get_figheight() == _default_height
def test_absolute_figure_size(): apply_style() fig = create_figure(width=11, height=7) assert fig.get_figwidth() == approx(11, 0.01) assert fig.get_figheight() == approx(7, 0.01)
#%% import numpy as np import matplotlib.pyplot as plt from figure_tools import apply_style, create_figure, save_figure, print_image_metadata # %% apply_style() # %% fig = create_figure(width='1x') # ... put your own plotting logic here # ... # ... x = np.linspace(0, 10, 100) plt.plot(x, np.sin(x), '-') plt.plot(x, np.sin(2.3 * x), '-') plt.xlabel('$t$ / s') plt.ylabel('amplitude') plt.title('awesome figure title') # ... # ... # ... plt.tight_layout() # Save the current figure in "png" format. The image will have the same # name as the python script, except for another suffix. save_figure(__file__) # %%