@@ -263,17 +263,6 @@ def _table(obj, data): # noqa: C901
263
263
# don't want the \n in the table definition, just in the data (below)
264
264
opts .append ("row sep=" + data ["table_row_sep" ].strip ())
265
265
266
- if data ["externalize tables" ] and data ["externals search path" ] is not None :
267
- esp = data ["externals search path" ]
268
- opts .append (f"search path={{{ esp } }}" )
269
-
270
- if len (opts ) > 0 :
271
- opts_str = "," .join (opts )
272
- content .append (f"table [{ opts_str } ] {{" )
273
- else :
274
- content .append ("table {" )
275
-
276
- plot_table = []
277
266
table_row_sep = data ["table_row_sep" ]
278
267
ydata [ydata_mask ] = np .nan
279
268
if np .any (ydata_mask ) or ~ np .all (np .isfinite (ydata )):
@@ -283,18 +272,34 @@ def _table(obj, data): # noqa: C901
283
272
if "unbounded coords=jump" not in data ["current axes" ].axis_options :
284
273
data ["current axes" ].axis_options .append ("unbounded coords=jump" )
285
274
286
- for x , y in zip (xdata , ydata ):
287
- plot_table .append (f"{ x :{xformat }} { col_sep } { y :{ff }} { table_row_sep } " )
275
+ plot_table = [
276
+ f"{ x :{xformat }} { col_sep } { y :{ff }} { table_row_sep } " for x , y in zip (xdata , ydata )
277
+ ]
278
+
279
+ min_extern_length = 3
288
280
289
- if data ["externalize tables" ]:
281
+ if data ["externalize tables" ] and len ( xdata ) >= min_extern_length :
290
282
filepath , rel_filepath = _files .new_filepath (data , "table" , ".dat" )
291
283
with open (filepath , "w" ) as f :
292
284
# No encoding handling required: plot_table is only ASCII
293
285
f .write ("" .join (plot_table ))
294
- content .append (str (rel_filepath ))
286
+
287
+ if data ["externals search path" ] is not None :
288
+ esp = data ["externals search path" ]
289
+ opts .append (f"search path={{{ esp } }}" )
290
+
291
+ if len (opts ) > 0 :
292
+ opts_str = "," .join (opts )
293
+ content .append (f"table [{ opts_str } ] {{{ rel_filepath } }};\n " )
294
+ else :
295
+ content .append (f"table {{{ rel_filepath } }};\n " )
295
296
else :
296
- content .append ("%\n " )
297
+ if len (opts ) > 0 :
298
+ opts_str = "," .join (opts )
299
+ content .append (f"table [{ opts_str } ] {{%\n " )
300
+ else :
301
+ content .append ("table {%\n " )
297
302
content .extend (plot_table )
303
+ content .append ("};\n " )
298
304
299
- content .append ("};\n " )
300
305
return content , axis_options
0 commit comments