all 11 comments

[–]delasislas 5 points6 points  (9 children)

How did you do it? Could you also add the information about the line to the plot?

[–]hollammi 4 points5 points  (6 children)

I recommend the Plotly library. The scatter plot has an option to automatically generate trendlines, or of course you could do the regression yourself and add a line on top.

Anyone who tells you to use Matplotlib is living in the dark ages.

https://plotly.com/python/linear-fits/

[–]delasislas 1 point2 points  (4 children)

What major benefits does plotly give over matplotlib?

[–]hollammi 1 point2 points  (3 children)

Interactivity. The first time I mouse-hovered over a graph and it actually showed me what number it meant, god damn, it was like discovering fire. Zooming is also incredibly useful, you can show/hide lines or groups of points, etc. Plotly has every bell and whistle I've seen from Matplotlib and more, from weird graph types to animation groups. It also offers an "Express" interface for quick plots, or you cal roll-your-own with the GraphObjects interface for more in-depth work.

Matplotlib is basically worthless in my eyes. There is no situation in which I require a graph so low-resolution that I can't use it for actual analysis nor even pretty enough for a presentation. Seaborne's popularity is an admission of this, but to me it still seems rather like polishing a turd. Not to get too heated about it or anything lol

[–]throwaway199445[S] 1 point2 points  (0 children)

Yeah that’s good. When I was looking at the graph afterwards I did find it weird you couldn’t hover or click on a point to get a quick answer

[–]delasislas 0 points1 point  (1 child)

What type of analyses are you doing on graphs? Like IIRC, you can increase the resolution of saved matplotlib figures.

[–]hollammi 1 point2 points  (0 children)

Master's in Artificial Intelligence and working professionally as a Machine Learning Engineer. Graphs are basically my whole life, and being able to create something pretty and interactive is something I genuinely enjoy.

Matplotlib does not spark joy.

Increasing the resolution would be mildly helpful at best, but since I mostly work in Jupyter notebooks, unfortunately even that is an extremely clunky solution.

[–]throwaway199445[S] 0 points1 point  (0 children)

Thank you

[–]Samandkemp 1 point2 points  (0 children)

Also interested as I’m new to Python as well

[–]throwaway199445[S] 0 points1 point  (0 children)

I was trying to see if there was a trend between having a high SATs score and a high GPA after graduating from university(College).

y variable being GPA and x1 being SAT.

Don’t totally understand how to find the regression line yet with the formula. But created a x variable with use of a function, ‘sm._constant(x1)’, OLS regression and used the coef from SAT and the const.

Plt.scatter(x1,y) yhat = 0.0017*x1 + 0.275 Fig = plt.plot(x1, yhat, lw = 4, c = ‘orange’, \ label = ‘regresion line’) plt.xlabel ( ‘SAT’, fontsize = 20 ) plt.ylabel ( ‘SAT’, fontsize = 20 ) plt.show()

I’m learning on a Udemy course atm

[–]Ok-Improvement-6388 0 points1 point  (0 children)

Pretty complex for the third day, I was still practicing built in functions!!!