diff --git a/pygmt/src/legend.py b/pygmt/src/legend.py index fcf5afac82d..e5a7ebefab0 100644 --- a/pygmt/src/legend.py +++ b/pygmt/src/legend.py @@ -8,6 +8,7 @@ build_arg_list, data_kind, fmt_docstring, + is_nonstr_iter, kwargs_to_strings, use_alias, ) @@ -77,7 +78,8 @@ def legend(self, spec=None, position="JTR+jTR+o0.2c", box="+gwhite+p1p", **kwarg with Session() as lib: if spec is None: specfile = "" - elif data_kind(spec) == "file": + elif data_kind(spec) == "file" and not is_nonstr_iter(spec): + # Is a file but not a list of files specfile = spec else: raise GMTInvalidInput(f"Unrecognized data type: {type(spec)}")