Skip to content

Commit

Permalink
Refactor test_legend_entries to use mpl_image_compare
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Mar 22, 2021
1 parent 6d8fb52 commit 03d95d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
Binary file removed pygmt/tests/baseline/test_legend_entries.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_legend_entries.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 4d1ed417fd2625d0b2fa5c17dafd32fd
size: 73728
path: test_legend_entries.png
34 changes: 8 additions & 26 deletions pygmt/tests/test_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pygmt import Figure
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import GMTTempFile
from pygmt.helpers.testing import check_figures_equal


@pytest.mark.mpl_image_compare
Expand Down Expand Up @@ -44,42 +43,25 @@ def test_legend_default_position():
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_legend_entries():
"""
Test different marker types/shapes.
"""
fig_ref, fig_test = Figure(), Figure()

# Use single-character arguments for the reference image
fig_ref = Figure()
fig_ref.basemap(J="x1i", R="0/7/3/7", B="")
fig_ref.plot(
data="@Table_5_11.txt",
S="c0.15i",
G="lightgreen",
W="faint",
l="Apples",
)
fig_ref.plot(data="@Table_5_11.txt", W="1.5p,gray", l='"My lines"')
fig_ref.plot(data="@Table_5_11.txt", S="t0.15i", G="orange", l="Oranges")
fig_ref.legend(D="JTR+jTR")

fig_test.basemap(projection="x1i", region=[0, 7, 3, 7], frame=True)
fig_test.plot(
fig = Figure()
fig.basemap(projection="x1i", region=[0, 7, 3, 7], frame=True)
fig.plot(
data="@Table_5_11.txt",
style="c0.15i",
color="lightgreen",
pen="faint",
label="Apples",
)
fig_test.plot(data="@Table_5_11.txt", pen="1.5p,gray", label='"My lines"')
fig_test.plot(
data="@Table_5_11.txt", style="t0.15i", color="orange", label="Oranges"
)
fig_test.legend(position="JTR+jTR")
fig.plot(data="@Table_5_11.txt", pen="1.5p,gray", label='"My lines"')
fig.plot(data="@Table_5_11.txt", style="t0.15i", color="orange", label="Oranges")
fig.legend(position="JTR+jTR")

return fig_ref, fig_test
return fig


@pytest.mark.mpl_image_compare
Expand Down

0 comments on commit 03d95d5

Please sign in to comment.