2
2
legend - Plot a legend.
3
3
"""
4
4
5
- import io
6
5
import pathlib
7
6
8
7
from pygmt .clib import Session
31
30
@kwargs_to_strings (R = "sequence" , c = "sequence_comma" , p = "sequence" )
32
31
def legend (
33
32
self ,
34
- spec : str | pathlib .PurePath | io . StringIO | None = None ,
33
+ spec : str | pathlib .PurePath | None = None ,
35
34
position = "JTR+jTR+o0.2c" ,
36
35
box = "+gwhite+p1p" ,
37
36
** kwargs ,
@@ -57,7 +56,6 @@ def legend(
57
56
- ``None`` means using the automatically generated legend specification file.
58
57
- A string or a :class:`pathlib.PurePath` object pointing to the legend
59
58
specification file.
60
- - A :class:`io.StringIO` object containing the legend specification.
61
59
62
60
See :gmt-docs:`legend.html` for the definition of the legend specification.
63
61
{projection}
@@ -90,11 +88,10 @@ def legend(
90
88
kwargs ["F" ] = box
91
89
92
90
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
94
92
raise GMTInvalidInput (f"Unrecognized data type: { type (spec )} " )
95
93
if kind == "file" and is_nonstr_iter (spec ):
96
94
raise GMTInvalidInput ("Only one legend specification file is allowed." )
97
95
98
96
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 ))
0 commit comments