tikzplotlib
tikzplotlib copied to clipboard
Error after running clean_figure on a scatter plot
trafficstars
This error seems to happen when there is overlapping points and a color sequence is specified.
ax.scatter([1,2,3], [1,2,3], c = [1,1,1]) and ax.scatter([1,1,1], [1,1,1]) are fine, but not ax.scatter([1,1,1], [1,1,1], c = [1,1,1]).
Minimal example
import matplotlib.pyplot as plt
import tikzplotlib
fig, ax = plt.subplots()
ax.scatter([1,1,1], [1,1,1], c = [1,1,1])
tikzplotlib.get_tikz_code(figure=fig) # OK
tikzplotlib.clean_figure(fig)
tikzplotlib.get_tikz_code(figure=fig) # Fail
Stacktrace
Traceback (most recent call last):
File "test.py", line 11, in <module>
tikzplotlib.get_tikz_code(figure=fig)
File "/home/maxmouchet/Applications/anaconda3/lib/python3.7/site-packages/tikzplotlib/_save.py", line 190, in get_tikz_code
data, content = _recurse(data, figure)
File "/home/maxmouchet/Applications/anaconda3/lib/python3.7/site-packages/tikzplotlib/_save.py", line 353, in _recurse
data, children_content = _recurse(data, child)
File "/home/maxmouchet/Applications/anaconda3/lib/python3.7/site-packages/tikzplotlib/_save.py", line 378, in _recurse
data, cont = _draw_collection(data, child)
File "/home/maxmouchet/Applications/anaconda3/lib/python3.7/site-packages/tikzplotlib/_save.py", line 319, in _draw_collection
return _path.draw_pathcollection(data, child)
File "/home/maxmouchet/Applications/anaconda3/lib/python3.7/site-packages/tikzplotlib/_path.py", line 128, in draw_pathcollection
dd = numpy.column_stack([dd, obj.get_array()])
File "<__array_function__ internals>", line 6, in column_stack
File "/home/maxmouchet/Applications/anaconda3/lib/python3.7/site-packages/numpy/lib/shape_base.py", line 656, in column_stack
return _nx.concatenate(arrays, 1)
File "<__array_function__ internals>", line 6, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 2 and the array at index 1 has size 3
Versions
matplotlib 3.1.3 and matplotlib 3.2.1
tikzplotlib 0.9.1
Easiest workaround is to duplicate the single point and plot it twice on top of eachother.