Skip to content

Commit 0e4faaa

Browse files
committed
Cherry-pick PR nschloe#617: Support table_row_sep in _path.py
1 parent 6976632 commit 0e4faaa

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/tikzplotlib/_line2d.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,15 @@ def _table(obj, data): # noqa: C901
259259
xformat = ff
260260
col_sep = " "
261261

262-
if data["table_row_sep"] != "\n":
262+
table_row_sep = data["table_row_sep"]
263+
if table_row_sep.strip() == r"\\" and data["externalize tables"]:
264+
# work around ! Package pgfplots Error: Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files.
265+
table_row_sep = "\n"
266+
267+
if table_row_sep != "\n":
263268
# don't want the \n in the table definition, just in the data (below)
264-
opts.append("row sep=" + data["table_row_sep"].strip())
269+
opts.append("row sep=" + table_row_sep.strip())
265270

266-
table_row_sep = data["table_row_sep"]
267271
ydata[ydata_mask] = np.nan
268272
if np.any(ydata_mask) or ~np.all(np.isfinite(ydata)):
269273
# matplotlib jumps at masked or nan values, while PGFPlots by default

src/tikzplotlib/_path.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ def draw_pathcollection(data, obj):
127127

128128
is_filled = False
129129

130+
table_row_sep = data["table_row_sep"]
131+
if table_row_sep.strip() == r"\\" and data["externalize tables"]:
132+
# work around ! Package pgfplots Error: Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files.
133+
table_row_sep = "\n"
134+
135+
if table_row_sep != "\n":
136+
# don't want the \n in the table definition, just in the data (below)
137+
table_options.append("row sep=" + table_row_sep.strip())
138+
139+
140+
130141
if obj.get_array() is not None:
131142
dd_strings = np.column_stack([dd_strings, obj.get_array()])
132143
labels.append("colordata")
@@ -302,9 +313,9 @@ def draw_pathcollection(data, obj):
302313
content.append("table{")
303314

304315
plot_table = []
305-
plot_table.append(" ".join(labels) + "\n")
316+
plot_table.append(" ".join(labels) + table_row_sep)
306317
for row in dd_strings:
307-
plot_table.append(" ".join(row) + "\n")
318+
plot_table.append(" ".join(row) + table_row_sep)
308319

309320
if data["externalize tables"]:
310321
filepath, rel_filepath = _files.new_filepath(data, "table", ".dat")

0 commit comments

Comments
 (0)