File tree 1 file changed +10
-24
lines changed
1 file changed +10
-24
lines changed Original file line number Diff line number Diff line change 3
3
Does not define any special non-GMT methods (savefig, show, etc).
4
4
"""
5
5
import contextlib
6
- import csv
7
6
import numpy as np
8
7
import pandas as pd
9
8
14
13
dummy_context ,
15
14
data_kind ,
16
15
fmt_docstring ,
17
- GMTTempFile ,
18
16
use_alias ,
19
17
kwargs_to_strings ,
20
18
)
@@ -986,28 +984,16 @@ def text(
986
984
if position is not None and isinstance (position , str ):
987
985
kwargs ["F" ] += f'+c{ position } +t"{ text } "'
988
986
989
- with GMTTempFile (suffix = ".txt" ) as tmpfile :
990
- with Session () as lib :
991
- fname = textfiles if kind == "file" else ""
992
- if kind == "vectors" :
993
- if position is not None :
994
- fname = ""
995
- else :
996
- pd .DataFrame .from_dict (
997
- {
998
- "x" : np .atleast_1d (x ),
999
- "y" : np .atleast_1d (y ),
1000
- "text" : np .atleast_1d (text ),
1001
- }
1002
- ).to_csv (
1003
- tmpfile .name ,
1004
- sep = "\t " ,
1005
- header = False ,
1006
- index = False ,
1007
- quoting = csv .QUOTE_NONE ,
1008
- )
1009
- fname = tmpfile .name
1010
-
987
+ with Session () as lib :
988
+ file_context = dummy_context (textfiles ) if kind == "file" else ""
989
+ if kind == "vectors" :
990
+ if position is not None :
991
+ file_context = dummy_context ("" )
992
+ else :
993
+ file_context = lib .virtualfile_from_vectors (
994
+ np .atleast_1d (x ), np .atleast_1d (y ), np .atleast_1d (text )
995
+ )
996
+ with file_context as fname :
1011
997
arg_str = " " .join ([fname , build_arg_string (kwargs )])
1012
998
lib .call_module ("text" , arg_str )
1013
999
You can’t perform that action at this time.
0 commit comments