tikzplotlib
tikzplotlib copied to clipboard
Seaborn scatterplot example does not work
This example from seaborn does not create any output: https://seaborn.pydata.org/examples/scatterplot_sizes.html
MWE python:
import tikzplotlib
import seaborn as sns
sns.set()
planets = sns.load_dataset("planets")
cmap = sns.cubehelix_palette(rot=-0.2, as_cmap=True)
ax = sns.scatterplot(
x="distance",
y="orbital_period",
hue="year",
size="mass",
palette=cmap,
sizes=(10, 200),
data=planets,
)
tikzplotlib.save("scatter_test.tikz")
Traceback from python:
Traceback (most recent call last):
File "testing.py", line 104, in <module>
testing()
File "testing.py", line 36, in testing
tikzplotlib.save("scatter_test.tikz")
File "/home/.../lib/python3.7/site-packages/tikzplotlib/_save.py", line 253, in save
code = get_tikz_code(*args, filepath=filepath, **kwargs)
File "/home/.../lib/python3.7/site-packages/tikzplotlib/_save.py", line 194, in get_tikz_code
data, content = _recurse(data, figure)
File "/home/.../lib/python3.7/site-packages/tikzplotlib/_save.py", line 345, in _recurse
data, children_content = _recurse(data, child)
File "/home/.../lib/python3.7/site-packages/tikzplotlib/_save.py", line 375, in _recurse
data, cont = _path.draw_pathcollection(data, child)
File "/home/.../lib/python3.7/site-packages/tikzplotlib/_path.py", line 171, in draw_pathcollection
and numpy.max(numpy.abs(path.vertices - p.vertices)) < 1.0e-10
File "/home/.../lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 2505, in amax
initial=initial)
File "/home/.../lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation maximum which has no identity
tikzplotlib version:
Name: tikzplotlib
Version: 0.8.6
Summary: Convert matplotlib figures into TikZ/PGFPlots
Home-page: https://github.com/nschloe/tikzplotlib
Author: Nico Schlömer
Author-email: [email protected]
License: License :: OSI Approved :: MIT License
Location: /home/.../lib/python3.7/site-packages
Requires: numpy, matplotlib, Pillow
Required-by:
seaborn version:
Name: seaborn
Version: 0.9.0
Summary: seaborn: statistical data visualization
Home-page: https://seaborn.pydata.org
Author: Michael Waskom
Author-email: [email protected]
License: BSD (3-clause)
Location: /home/.../lib/python3.7/site-packages
Requires: numpy, scipy, matplotlib, pandas
Required-by:
Having the same issue with seaborn 0.10.0 and tikzplotlib 0.9.0
Same here
Same issue here using tikzplotlib 0.9.8 and seaborn 0.11.1. Specifically, if sns.scatterplot is present in the figure, the output tikz file results empty. Instead, if sns.lineplot is used, the output tikz file works as expected.
Facing same issue with seaborn 0.9.0
and tikzplotlib 0.9.12
. Any fix for this?
I'm currently having the same issue with seaborn 0.12.2
and tikzplotlib 0.10.1
. Does anyone have any idea on a fix?
It is working for me using seaborn 0.11.2
and tikzplotlib 0.10.1
.
Example code:
import seaborn as sns
import tikzplotlib
sns.scatterplot(x=range(10), y=range(10))
tikzplotlib.save("tmp.tikz")
yields
% tmp.tikz
% 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.45, xmax=9.45,
xtick style={color=black},
y grid style={darkgray176},
ymin=-0.45, ymax=9.45,
ytick style={color=black}
]
\addplot [draw=white, fill=steelblue31119180, mark=*, only marks]
table{%
x y
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
};
\end{axis}
\end{tikzpicture}
when rendered: