nschloe / tikzplotlib

:bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.
MIT License
2.43k stars 218 forks source link

Scatter plot fails for a single point #594

Open machur opened 1 year ago

machur commented 1 year ago

Scatter plot fails for a single point. A work-around is to pass list with the same point twice, but it looks like there's an error with one-element arrays:

Code that fails:

    plt.scatter([0.5, 0.3, 0.2], [0.2, 0.3, 0.5], s=10, color="red")
    plt.scatter([0.4], [0.4], s=10, color="blue")

Erroneous result: image

Hackish way of plotting:

    plt.scatter([0.5, 0.3, 0.2], [0.2, 0.3, 0.5], s=10, color="red")
    plt.scatter([0.4, 0.4], [0.4, 0.4], s=10, color="blue")  # doubled point

Result as expected: image

JasonGross commented 6 months ago

This is presumably caused by https://github.com/nschloe/tikzplotlib/blob/450712b4014799ec5f151f234df84335c90f4b9d/src/tikzplotlib/_path.py#L232 being a bad proxy for "is it a contour"