From 43133e21fb8836329ba4fda29dd977c1f644a7dd Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Sat, 25 May 2024 20:01:57 -0700 Subject: [PATCH 1/2] Support table_row_sep in _path.py --- src/tikzplotlib/_path.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tikzplotlib/_path.py b/src/tikzplotlib/_path.py index 11381d59..eb404c11 100644 --- a/src/tikzplotlib/_path.py +++ b/src/tikzplotlib/_path.py @@ -127,6 +127,13 @@ def draw_pathcollection(data, obj): is_filled = False + if data["table_row_sep"] != "\n": + # don't want the \n in the table definition, just in the data (below) + table_options.append("row sep=" + data["table_row_sep"].strip()) + + table_row_sep = data["table_row_sep"] + + if obj.get_array() is not None: dd_strings = np.column_stack([dd_strings, obj.get_array()]) labels.append("colordata") @@ -302,9 +309,9 @@ def draw_pathcollection(data, obj): content.append("table{") plot_table = [] - plot_table.append(" ".join(labels) + "\n") + plot_table.append(" ".join(labels) + table_row_sep) for row in dd_strings: - plot_table.append(" ".join(row) + "\n") + plot_table.append(" ".join(row) + table_row_sep) if data["externalize tables"]: filepath, rel_filepath = _files.new_filepath(data, "table", ".dat") From 6c2f13ace21432196d26c236c65ba5c7c7e24526 Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Sat, 25 May 2024 20:20:17 -0700 Subject: [PATCH 2/2] Fix for Package pgfplots Error: Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files. --- src/tikzplotlib/_line2d.py | 10 +++++++--- src/tikzplotlib/_path.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/tikzplotlib/_line2d.py b/src/tikzplotlib/_line2d.py index b431b869..c623515d 100644 --- a/src/tikzplotlib/_line2d.py +++ b/src/tikzplotlib/_line2d.py @@ -259,11 +259,15 @@ def _table(obj, data): # noqa: C901 xformat = ff col_sep = " " - if data["table_row_sep"] != "\n": + table_row_sep = data["table_row_sep"] + if table_row_sep.strip() == r"\\" and data["externalize tables"]: + # work around ! Package pgfplots Error: Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files. + table_row_sep = "\n" + + if table_row_sep != "\n": # don't want the \n in the table definition, just in the data (below) - opts.append("row sep=" + data["table_row_sep"].strip()) + opts.append("row sep=" + table_row_sep.strip()) - table_row_sep = data["table_row_sep"] ydata[ydata_mask] = np.nan if np.any(ydata_mask) or ~np.all(np.isfinite(ydata)): # matplotlib jumps at masked or nan values, while PGFPlots by default diff --git a/src/tikzplotlib/_path.py b/src/tikzplotlib/_path.py index eb404c11..a1ccfd50 100644 --- a/src/tikzplotlib/_path.py +++ b/src/tikzplotlib/_path.py @@ -127,11 +127,15 @@ def draw_pathcollection(data, obj): is_filled = False - if data["table_row_sep"] != "\n": + table_row_sep = data["table_row_sep"] + if table_row_sep.strip() == r"\\" and data["externalize tables"]: + # work around ! Package pgfplots Error: Sorry, the choice 'row sep=crcr' is currently only available for inline tables, not for external files. + table_row_sep = "\n" + + if table_row_sep != "\n": # don't want the \n in the table definition, just in the data (below) - table_options.append("row sep=" + data["table_row_sep"].strip()) + table_options.append("row sep=" + table_row_sep.strip()) - table_row_sep = data["table_row_sep"] if obj.get_array() is not None: