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?
            Asked
            
        
        
            Active
            
        
            Viewed 37 times
        
    0
            
            
         
    
    
        BullyWiiPlaza
        
- 17,329
- 10
- 113
- 185
- 
                    1It 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
- 
                    1Yes, 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
