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>try the following in terminal to check the backend:</p>

<pre><code>import matplotlib
import matplotlib.pyplot
print matplotlib.backends.backend
</code></pre>

<p>If it shows 'agg', it is a non-interactive one and wont show but plt.savefig works.</p>

<p>To show the plot, you need to switch to TkAgg or Qt4Agg.</p>

<p>You need to edit the backend in matplotlibrc file. To print its location in terminal do the following.</p>

<pre><code>import matplotlib
matplotlib.matplotlib_fname()
</code></pre>

<p>more about <a href="http://matplotlib.org/users/customizing.html#the-matplotlibrc-file" rel="nofollow">matplotlibrc</a></p>

python matplotlib linear-regression