File tree Expand file tree Collapse file tree 1 file changed +10
-24
lines changed Expand file tree Collapse file tree 1 file changed +10
-24
lines changed Original file line number Diff line number Diff line change 33Does not define any special non-GMT methods (savefig, show, etc).
44"""
55import contextlib
6- import csv
76import numpy as np
87import pandas as pd
98
1413 dummy_context ,
1514 data_kind ,
1615 fmt_docstring ,
17- GMTTempFile ,
1816 use_alias ,
1917 kwargs_to_strings ,
2018)
@@ -986,28 +984,16 @@ def text(
986984 if position is not None and isinstance (position , str ):
987985 kwargs ["F" ] += f'+c{ position } +t"{ text } "'
988986
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 :
1011997 arg_str = " " .join ([fname , build_arg_string (kwargs )])
1012998 lib .call_module ("text" , arg_str )
1013999
You can’t perform that action at this time.
0 commit comments