22legend - Plot a legend.
33"""
44
5- import io
65import pathlib
76
87from pygmt .clib import Session
3130@kwargs_to_strings (R = "sequence" , c = "sequence_comma" , p = "sequence" )
3231def 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 ))
0 commit comments