title: How to convert it back to datetime format?
body: <p>I wanted to perform arithmetic operations on dates so i converted these dates</p>
  
  <pre><code>idx_1 = 2017-06-07 00:00:00
  idx_2 = 2017-07-27 00:00:00 
  </code></pre>
  
  <p>to floats using,</p>
  
  <pre><code>x1 = time.mktime(idx_1.timetuple())  # returns float of dates
  &gt;&gt;&gt; 1496773800.0
  x2 = time.mktime(idx_2.timetuple())
  &gt;&gt;&gt; 1501093800.0
  y1 = 155.98
  y2 = 147.07
  </code></pre>
  
  <p>Am using the following code to plot:</p>
  
  <pre><code>    import datetime as dt
      import time
      import numpy as np
      import matplotlib.pyplot as plt
      x = [x1, x2]
      y = [y1, y2]
      Difference = x2 - x1 #this helps to end the plotted line at specific point
      coefficients = np.polyfit(x, y, 1)
      polynomial = np.poly1d(coefficients)
      # the np.linspace lets you set number of data points, line length.
      x_axis = np.linspace(x1, x2 + Difference, 3)  # linspace(start, end, num)
      y_axis = polynomial(x_axis)
      plt.plot(x_axis, y_axis)
      plt.plot(x[0], y[0], 'go')
      plt.plot(x[1], y[1], 'go')
      plt.show()
  </code></pre>
  
  <p>Which plots:
  <a href="https://i.stack.imgur.com/noMKr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/noMKr.png" alt="enter image description here"></a></p>
  
  <p>How to make matplotlib to plot the actual dates on x axis instead of floats?</p>
  
  <p>Any kind of Help is Greatly Appreciated.</p>