Esempio n. 1
0
def test_aspect_ratio_with_default_width():
    apply_style()
    fig = create_figure(aspect_ratio=2.0)
    assert fig.get_figwidth() == approx(_default_width, 0.01)
    assert fig.get_figheight() == approx(2 * _default_width, 0.01)
Esempio n. 2
0
def test_aspect_ratio_with_absolute_width():
    apply_style()
    fig = create_figure(width='120mm', aspect_ratio=0.5)
    assert fig.get_figwidth() == approx(120 / 25.4, 0.01)
    assert fig.get_figheight() == approx(0.5 * 120 / 25.4, 0.01)
Esempio n. 3
0
def test_figure_size_with_units():
    apply_style()
    fig = create_figure(width='80mm', height='6cm')
    assert fig.get_figwidth() == approx(80 / 25.4, 0.01)
    assert fig.get_figheight() == approx(6 / 2.54, 0.01)
Esempio n. 4
0
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)
Esempio n. 5
0
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)
Esempio n. 6
0
def test_default_figure_size():
    apply_style()
    fig = create_figure()
    assert fig.get_figwidth() == _default_width
    assert fig.get_figheight() == _default_height
#%%
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__)

# %%