tikzplotlib icon indicating copy to clipboard operation
tikzplotlib copied to clipboard

Percent sign (%) in descriptions (labels, titles, etc.) are not escaped

Open benHeid opened this issue 2 years ago • 0 comments
trafficstars

Thank you for your really nice package, which simplifies my workflow of writing. However, I have found a small error in your code.

Python Code

plt.plot([0,2,4,5,6]) plt.suptitle("%") tikzplotlib.save("test.tex")

Resulting tikz Code`

In the penultimate line the percent sign is not escaped, this results in an latex error because the closing bracket is now outcommented.

% This file was created with tikzplotlib v0.10.1.
\begin{tikzpicture}

\definecolor{darkgray176}{RGB}{176,176,176}
\definecolor{steelblue31119180}{RGB}{31,119,180}

\begin{axis}[
tick align=outside,
tick pos=left,
x grid style={darkgray176},
xmin=-0.2, xmax=4.2,
xtick style={color=black},
y grid style={darkgray176},
ymin=-0.3, ymax=6.3,
ytick style={color=black}
]
\addplot [semithick, steelblue31119180]
table {%
0 0
1 2
2 4
3 5
4 6
};
\end{axis}

\draw ({$(current bounding box.south west)!0.5!(current bounding box.south east)$}|-{$(current bounding box.south west)!0.98!(current bounding box.north west)$}) node[
  scale=0.6,
  anchor=north,
  text=black,
  rotate=0.0
]{%};
\end{tikzpicture}

benHeid avatar Mar 06 '23 08:03 benHeid