Fitting a regression line in python

Hi all,

I’m a very new user of plotly. I’m using the Python API (in offline mode) within an IPython notebook.
I have constructed a bubble plot (basically the same thing as a scatter plot with variable sized markers) which has turned out fine.

I would like to fit a linear regression line through the data and draw it on the existing figure.

I have seen examples of fitting being performed through the web interface, but haven’t found one using the Python API.
Are there any convenience functions that would allow me to do so in Python, or will I have to manually do it (i.e. using statsmodel (say) to find the equation of fit, followed by generating points satisfying the equation, and finally then drawing a line through the points on the figure)?

Note that I require a “proper” regression fit - I’m not looking for a ‘lines+markers’ mode sort of a thing.


Actually it turned out to be easy enough to do it “manually”, as I described it. I’m kinda in new territory (for me) here, so had overestimated the effort that would be needed. It makes sense for the plotly API not to offer regression fit functions - it is, after all, a plotting library, not a statistical library.