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 11381d59..a1ccfd50 100644 --- a/src/tikzplotlib/_path.py +++ b/src/tikzplotlib/_path.py @@ -127,6 +127,17 @@ def draw_pathcollection(data, obj): is_filled = False + 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=" + table_row_sep.strip()) + + + if obj.get_array() is not None: dd_strings = np.column_stack([dd_strings, obj.get_array()]) labels.append("colordata") @@ -302,9 +313,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")