Discontinuity in graphs but no discontinuity in data in plotting dataframes using matplotlib
<p>I'm trying to plot predictions using scikit-learn, pandas, and matplotlib.
I'm able to predict the data and able to save them in dataframes. But now when I plot them there are two cases.</p>

<h3>1st case</h3>

<p>I created a new column for the forecast predictions and plot them with the values i predicted from
<code>Adj. Close</code> is my feature and <code>forecast</code> are my predictions. As you can see the dates are matched perfectly so there shouldn't be any gaps.</p>

<p>My data:</p>

<pre><code>            HL_Precentage  Adj. High  Adj. Low  Adj. Close  Adj. Volume  \
Date                                                                      
2016-08-19       0.545879     801.23    796.88      799.65    1120763.0   
2016-08-22       0.625685     799.30    794.33      796.95     853365.0   
2016-08-23       0.629405     801.00    795.99      796.59     917513.0   
2016-08-24       0.973747     798.46    790.76      793.60    1284437.0   
2016-08-25            NaN        NaN       NaN         NaN          NaN   
2016-08-26            NaN        NaN       NaN         NaN          NaN   
2016-08-27            NaN        NaN       NaN         NaN          NaN   
2016-08-28            NaN        NaN       NaN         NaN          NaN   
2016-08-29            NaN        NaN       NaN         NaN          NaN   
2016-08-30            NaN        NaN       NaN         NaN          NaN 



             label    Forecast  
Date                            
2016-08-19  802.79         NaN  
2016-08-22  801.23         NaN  
2016-08-23  803.08         NaN  
2016-08-24  800.71         NaN  
2016-08-25     NaN  797.835059  
2016-08-26     NaN  799.896814  
2016-08-27     NaN  802.552861  
2016-08-28     NaN  798.483859  
2016-08-29     NaN  795.999011  
2016-08-30     NaN  797.866796 
</code></pre>

<p><img src="http://i.stack.imgur.com/tNHEq.png" alt="Image Link: red is Adj. Close and blue is forecast"></p>

<p>(red is <code>Adj. Close</code> and blue is forecast)</p>

<h3>2nd case</h3>

<p>To get rid of the gap I plugged the values of predictions in the <code>Adj. Close</code> column only and to my amusement the graph was a continuous one.</p>

<p>Data:</p>

<pre><code>            HL_Precentage  Adj. High  Adj. Low  Adj. Close  Adj. Volume  \
Date                                                                      
2016-08-19       0.545879     801.23    796.88  799.650000    1120763.0   
2016-08-22       0.625685     799.30    794.33  796.950000     853365.0   
2016-08-23       0.629405     801.00    795.99  796.590000     917513.0   
2016-08-24       0.973747     798.46    790.76  793.600000    1284437.0   
2016-08-25            NaN        NaN       NaN  796.877634          NaN   
2016-08-26            NaN        NaN       NaN  799.448407          NaN   
2016-08-27            NaN        NaN       NaN  801.340352          NaN   
2016-08-28            NaN        NaN       NaN  798.130538          NaN   
2016-08-29            NaN        NaN       NaN  794.900353          NaN   
2016-08-30            NaN        NaN       NaN  796.483742          NaN   

             label  Forecast  
Date                          
2016-08-19  802.79       NaN  
2016-08-22  801.23       NaN  
2016-08-23  803.08       NaN  
2016-08-24  800.71       NaN  
2016-08-25     NaN       NaN  
2016-08-26     NaN       NaN  
2016-08-27     NaN       NaN  
2016-08-28     NaN       NaN  
2016-08-29     NaN       NaN  
2016-08-30     NaN       NaN 
</code></pre>

<p><img src="http://i.stack.imgur.com/6MxqG.png" alt="Image Link: red line is for Adj. close"></p>

<p>My question is how to make my first graph continuous so as to make my predictions not discontinuous?</p>

<p>There <em>is</em> a discontinuity in your data - the last <code>Adj. close</code> value was recorded on 08/24 and the first <code>Forecast</code> value is for 08/25.</p>

<p>In order to have no breaks in the line you would need the ends of your two series to overlap by at least one timepoint. You could, for example, compute a <code>Forecast</code> for 08/24 where you also have an <code>Adj. close</code> value.</p>

python pandas matplotlib