Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support table_row_sep in _path.py #617

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/tikzplotlib/_line2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions src/tikzplotlib/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down