0

For my graph, I have constructed a series of points like so

 for x in range (0,9):
     plt.scatter(r[x],functions[x],color='green')

where r[x] and functions[x] are both arrays with 9 elements.

The scatter plot works fine; however, I was wondering if there was anyway I could draw a line instead of just some points. Or if I can draw a line through the points. Thanks in advance

S.Alber
  • 1
  • 1

2 Answers2

1

Do you mean a line connecting the points? In that case you can just do: plt.plot(r,functions,color='green') if r and functions contain more than 9 elements use: r[:9] and functions[:9].

T C Molenaar
  • 3,205
  • 1
  • 10
  • 26
-1

This might help: How to overplot a line on a scatter plot in python?

In case you are trying to plot a regression line through the points, which is a different case, maybe this would help: http://matthiaseisen.com/pp/patterns/p0170/

(I would've commented but I don't meet minimum reputation requirements. Hope I helped!)

Omkar Neogi
  • 675
  • 2
  • 9
  • 30