nschloe / tikzplotlib

:bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scatter plot: wrong marker rotation

dajuno opened this issue · comments

commented

Hello,

when exporting a scatter plot with tikzplotlib, using 'v' markers, there is an error with the marker rotation. Cf. the following MWE:

import matplotlib.pyplot as plt
import tikzplotlib

plt.figure()
plt.plot([0, 0], [0, 1], 'v')
tikzplotlib.save('plot.tikz')

plt.figure()
plt.scatter([0, 0], [0, 1], marker='v')
tikzplotlib.save('scatter.tikz')

Line plot export plot.tikz works fine:

% This file was created by tikzplotlib v0.9.4.
\begin{tikzpicture}

\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}

\begin{axis}[
tick align=outside,
tick pos=left,
x grid style={white!69.0196078431373!black},
xmin=-0.055, xmax=0.055,
xtick style={color=black},
y grid style={white!69.0196078431373!black},
ymin=-0.05, ymax=1.05,
ytick style={color=black}
]
\addplot [semithick, color0, mark=triangle*, mark size=3, mark options={solid,rotate=180}, only marks]
table {%
0 0
0 1
};
\end{axis}

\end{tikzpicture}

scatter.tikz rotates the entire plot, not only the markers:

% This file was created by tikzplotlib v0.9.4.
\begin{tikzpicture}

\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}

\begin{axis}[
tick align=outside,
tick pos=left,
x grid style={white!69.0196078431373!black},
xmin=-0.055, xmax=0.055,
xtick style={color=black},
y grid style={white!69.0196078431373!black},
ymin=-0.05, ymax=1.05,
ytick style={color=black}
]
\addplot [only marks, mark=triangle*, rotate=180, draw=color0, fill=color0, colormap/viridis]
table{%
x                      y
0 0
0 1
};
\end{axis}

\end{tikzpicture}

The scatter plot should apply rotate=180 as is done correctly for the line plot: mark options={rotate=180}.

Thanks for your work, best wishes

David