matplotlib.pyplot.plot() doesn't show the graph
<p>I am learning Python and I have a side project to learn to display data using matplotlib.pyplot module.  Here is an example to display the data using dates[] and prices[] as data.  Does anyone know why we need line 5 and line 6?  I am confused why this step is needed to have the graph displayed.   </p>

<pre><code>from sklearn import linear_model
import matplotlib.pyplot as plt

def showgraph(dates, prices):
  dates  = numpy.reshape(dates, (len(dates), 1))   # line 5
  prices = numpy.reshape(prices, (len(prices), 1)) # line 6

  linear_mod = linear_model.LinearRegression()
  linear_mod.fit(dates,prices)
  plt.scatter(dates,prices,color='yellow') 
  plt.plot(dates,linear_mod.predict(dates),color='green')
  plt.show()
</code></pre>

<p>My approach is exactly like yours but still without line 5 and 6 display is correct. I think those line are unnecessary. It seems that you do not need fit() function because of your input data are in row format.</p>

python matplotlib linear-regression