50
50
w = "wrap" ,
51
51
)
52
52
@kwargs_to_strings (R = "sequence" , c = "sequence_comma" , i = "sequence_comma" , p = "sequence" )
53
- def plot (
53
+ def plot ( # noqa: PLR0912
54
54
self ,
55
55
data = None ,
56
56
x = None ,
@@ -232,34 +232,37 @@ def plot(
232
232
kwargs = self ._preprocess (** kwargs )
233
233
234
234
kind = data_kind (data )
235
- extra_arrays = []
236
- if kind == "empty " : # Add more columns for vectors input
235
+ if kind == "empty" : # Data is given via a series of vectors.
236
+ data = { "x " : x , "y" : y }
237
237
# Parameters for vector styles
238
238
if (
239
239
isinstance (kwargs .get ("S" ), str )
240
240
and len (kwargs ["S" ]) >= 1
241
241
and kwargs ["S" ][0 ] in "vV"
242
242
and is_nonstr_iter (direction )
243
243
):
244
- extra_arrays . extend ( direction )
244
+ data . update ({ "x2" : direction [ 0 ], "y2" : direction [ 1 ]} )
245
245
# Fill
246
246
if is_nonstr_iter (kwargs .get ("G" )):
247
- extra_arrays . append ( kwargs . get ( "G" ))
247
+ data [ "fill" ] = kwargs [ "G" ]
248
248
del kwargs ["G" ]
249
249
# Size
250
250
if is_nonstr_iter (size ):
251
- extra_arrays . append ( size )
251
+ data [ " size" ] = size
252
252
# Intensity and transparency
253
- for flag in ["I" , "t " ]:
253
+ for flag , name in ["I" , "intensity" ], [ "t" , "transparency " ]:
254
254
if is_nonstr_iter (kwargs .get (flag )):
255
- extra_arrays . append ( kwargs . get ( flag ))
255
+ data [ name ] = kwargs [ flag ]
256
256
kwargs [flag ] = ""
257
257
# Symbol must be at the last column
258
258
if is_nonstr_iter (symbol ):
259
259
if "S" not in kwargs :
260
260
kwargs ["S" ] = True
261
- extra_arrays . append ( symbol )
261
+ data [ " symbol" ] = symbol
262
262
else :
263
+ if any (v is not None for v in (x , y )):
264
+ msg = "Too much data. Use either data or x/y/z."
265
+ raise GMTInvalidInput (msg )
263
266
for name , value in [
264
267
("direction" , direction ),
265
268
("fill" , kwargs .get ("G" )),
@@ -277,7 +280,5 @@ def plot(
277
280
kwargs ["S" ] = "s0.2c"
278
281
279
282
with Session () as lib :
280
- with lib .virtualfile_in (
281
- check_kind = "vector" , data = data , x = x , y = y , extra_arrays = extra_arrays
282
- ) as vintbl :
283
+ with lib .virtualfile_in (check_kind = "vector" , data = data ) as vintbl :
283
284
lib .call_module (module = "plot" , args = build_arg_list (kwargs , infile = vintbl ))
0 commit comments