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

Error after running clean_figure on a scatter plot #403

Open
maxmouchet opened this issue May 7, 2020 · 1 comment
Open

Error after running clean_figure on a scatter plot #403

maxmouchet opened this issue May 7, 2020 · 1 comment

Comments

@maxmouchet
Copy link

maxmouchet commented May 7, 2020

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

@J-Lips
Copy link

J-Lips commented Nov 14, 2023

Easiest workaround is to duplicate the single point and plot it twice on top of eachother.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants