Skip to content

Commit 2ac4386

Browse files
committed
Fix text
1 parent bbd8532 commit 2ac4386

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pygmt/src/text.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
w="wrap",
4343
)
4444
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
45-
def text_( # noqa: PLR0912
45+
def text_( # noqa: PLR0912, PLR0915
4646
self,
4747
textfiles=None,
4848
x=None,
@@ -222,22 +222,25 @@ def text_( # noqa: PLR0912
222222
elif isinstance(arg, int | float | str):
223223
kwargs["F"] += f"{flag}{arg}"
224224

225-
extra_arrays = []
226225
confdict = {}
226+
data = None
227227
if kind == "empty":
228+
data = {"x": x, "y": y}
229+
x, y = None, None
230+
228231
for arg, flag, name in array_args:
229232
if is_nonstr_iter(arg):
230233
kwargs["F"] += flag
231234
# angle is numeric type and font/justify are str type.
232235
if name == "angle":
233-
extra_arrays.append(arg)
236+
data["angle"] = arg
234237
else:
235-
extra_arrays.append(np.asarray(arg, dtype=np.str_))
238+
data[name] = np.asarray(arg, dtype=np.str_)
236239

237240
# If an array of transparency is given, GMT will read it from the last numerical
238241
# column per data record.
239242
if is_nonstr_iter(kwargs.get("t")):
240-
extra_arrays.append(kwargs["t"])
243+
data["transparency"] = kwargs["t"]
241244
kwargs["t"] = True
242245

243246
# Append text to the last column. Text must be passed in as str type.
@@ -247,7 +250,7 @@ def text_( # noqa: PLR0912
247250
text, encoding=encoding
248251
)
249252
confdict["PS_CHAR_ENCODING"] = encoding
250-
extra_arrays.append(text)
253+
data["text"] = text
251254
else:
252255
if isinstance(position, str):
253256
kwargs["F"] += f"+c{position}+t{text}"
@@ -260,10 +263,9 @@ def text_( # noqa: PLR0912
260263
with Session() as lib:
261264
with lib.virtualfile_in(
262265
check_kind="vector",
263-
data=textfiles,
266+
data=textfiles or data,
264267
x=x,
265268
y=y,
266-
extra_arrays=extra_arrays,
267269
required_data=required_data,
268270
) as vintbl:
269271
lib.call_module(

0 commit comments

Comments
 (0)