title: Adding UTC time axis to plot with local time in time format
body: <p>I have a DataFrame plot which looks something like this </p>
  
  <p><a href="https://i.stack.imgur.com/gl6cP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gl6cP.png" alt="enter image description here"></a></p>
  
  <p>The index on the plotted DataFrame is as follows </p>
  
  <pre><code>In[102]: res.index
  Out[102]: 
  Index([00:00:00, 00:05:00, 00:10:00, 00:15:00, 00:20:00, 00:25:00, 00:30:00,
         00:35:00, 00:40:00, 00:45:00,
         ...
         23:10:00, 23:15:00, 23:20:00, 23:25:00, 23:30:00, 23:35:00, 23:40:00,
         23:45:00, 23:50:00, 23:55:00],
        dtype='object', name='time', length=288)
  </code></pre>
  
  <p>The times depicted on the x-axis are in Central Standard Time, and I would like to add a secondary x-axis to the top of the plot with the corresponding UTC times. I'm aware that this will make the numbers go <code>6:00 ... 22:00 ... 4:00</code> but that is fine. <strong>How can I do so</strong>?</p>
  
  <hr>
  
  <h3>My attempts</h3>
  
  <p>I know that a second x-axis can be created with the following, and I managed to procure what seems like the <code>xticks</code> from the first x-axis with the following - my next step was going to be to try to determine how to shift these times to UTC - which I am still unsure on ideas for. </p>
  
  <pre><code>ax2 = ax.twiny()
  ax2.set_xlabel('UTC time')
  local_ticks = ax.get_xticks().tolist()
  </code></pre>
  
  <p>However upon plotting this rudimentary step, I found that <code>get_xticks()</code> has yielded one extra tick than the original x-axis, and so they are not aligned. </p>
  
  <p><a href="https://i.stack.imgur.com/x0X1L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x0X1L.png" alt="enter image description here"></a></p>
  
  <p>Correspondingly, treating these as seconds and attempting to perform some further manipulations to go seconds->CST->UTC is still going to leave me with the ugly scaling "double white-line" at each tick. Ideally, I want the <em>exact same</em> ticks along the secondary x-axis, except with appropriately labelled UTC times. </p>
  
  <hr>
  
  <h3>Sample generation</h3>
  
  <p>If you want to generate a plot like the first one I provided, I threw this together. </p>
  
  <pre><code>import datetime
  
  import numpy as np
  import random
  import pandas as pd
  import matplotlib.pyplot as plt
  plt.style.use('ggplot')
  start_date = datetime.datetime(2016, 9, 5)
  end_date = datetime.datetime.now()
  
  dts = []
  cur_date = start_date 
  while cur_date &lt; end_date:
      dts.append((cur_date, np.random.uniform(low=0.0, high=12.0)))
      cur_date += datetime.timedelta(minutes=np.random.uniform(10, 20))
  dts = pd.DataFrame(dts, columns=['timestamp', 'lag'])
  dts.index = dts.timestamp
  dts.drop('timestamp', axis=1, inplace=True)
  
  cur_time = datetime.datetime(1, 1, 1, 0, 0)
  aggs = []
  while cur_time &lt; datetime.datetime(1, 1, 1, 23, 59, 0):
      aggs.append((cur_time.time(), 
                  dts.between_time(cur_time.time(),
                  (cur_time + datetime.timedelta(minutes=5)).time(), 
                  include_end=False)['lag'].mean()))
      cur_time += datetime.timedelta(minutes=5)
  
  res = pd.DataFrame(aggs, columns = ['time', 'lag'])
  res.index = res.time
  res.drop('time', axis=1, inplace=True)
  
  ax = res.plot(figsize=(15, 10))
  </code></pre>