0

I'm trying to draw a regression curve through my x and y data. I'm using the code provided in this answer. The final figure however contains multiple red lines instead of just a single one which looks cluttered. How is this caused and is there a way to just draw a single fitted graph?

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
  • 1
    It connects all the points from each point. Instead `plt.plot(x, func(x, *popt), 'r-', label="Fitted Curve")`, try `plt.scatter(x, func(x, *popt), 'r-', label="Fitted Curve")` – Naveen Nov 14 '18 at 15:52
  • You're going to have to show some code for us to know how to help. But I suspect what @Naveen pointed out is part of the problem. – busybear Nov 14 '18 at 15:54
  • 1
    Yes, sorting before plotting the regression curve was the key as demonstrated in this answer: https://stackoverflow.com/a/42999161/3764804 :) – BullyWiiPlaza Nov 14 '18 at 16:10

0 Answers0