Skip to content

Commit deb917d

Browse files
committed
Revert changes in legend
1 parent 4e4bd2d commit deb917d

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

pygmt/src/legend.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
legend - Plot a legend.
33
"""
44

5-
import io
65
import pathlib
76

87
from pygmt.clib import Session
@@ -31,7 +30,7 @@
3130
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
3231
def legend(
3332
self,
34-
spec: str | pathlib.PurePath | io.StringIO | None = None,
33+
spec: str | pathlib.PurePath | None = None,
3534
position="JTR+jTR+o0.2c",
3635
box="+gwhite+p1p",
3736
**kwargs,
@@ -57,7 +56,6 @@ def legend(
5756
- ``None`` means using the automatically generated legend specification file.
5857
- A string or a :class:`pathlib.PurePath` object pointing to the legend
5958
specification file.
60-
- A :class:`io.StringIO` object containing the legend specification.
6159
6260
See :gmt-docs:`legend.html` for the definition of the legend specification.
6361
{projection}
@@ -90,11 +88,10 @@ def legend(
9088
kwargs["F"] = box
9189

9290
kind = data_kind(spec)
93-
if kind not in {"vectors", "file", "stringio"}: # kind="vectors" means spec is None
91+
if kind not in {"vectors", "file"}: # kind="vectors" means spec is None
9492
raise GMTInvalidInput(f"Unrecognized data type: {type(spec)}")
9593
if kind == "file" and is_nonstr_iter(spec):
9694
raise GMTInvalidInput("Only one legend specification file is allowed.")
9795

9896
with Session() as lib:
99-
with lib.virtualfile_in(data=spec, required_data=False) as vintbl:
100-
lib.call_module(module="legend", args=build_arg_list(kwargs, infile=vintbl))
97+
lib.call_module(module="legend", args=build_arg_list(kwargs, infile=spec))

pygmt/tests/test_legend.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test Figure.legend.
33
"""
44

5-
import io
65
from pathlib import Path
76

87
import pytest
@@ -101,18 +100,6 @@ def test_legend_specfile(legend_spec):
101100
fig = Figure()
102101
fig.basemap(projection="x6i", region=[0, 1, 0, 1], frame=True)
103102
fig.legend(specfile.name, position="JTM+jCM+w5i")
104-
return fig
105-
106-
107-
@pytest.mark.mpl_image_compare(filename="test_legend_specfile.png")
108-
def test_legend_stringio(legend_spec):
109-
"""
110-
Test passing an legend specification via an io.StringIO object.
111-
"""
112-
spec = io.StringIO(legend_spec)
113-
fig = Figure()
114-
fig.basemap(projection="x6i", region=[0, 1, 0, 1], frame=True)
115-
fig.legend(spec, position="JTM+jCM+w5i")
116103
return fig
117104

118105

0 commit comments

Comments
 (0)