title: Issues in Plotting Intraday OHLC Chart with Matplotlib
body: <p>I am trying to plot OHLC candlestick chart (1Min) for complete one day and want to show 'Hours' as Major locator and Min as minor locator.
  Hour locator should be displayed as till end of data
  Major Locator
  09:00
  10:00
  11:00 and so on.</p>
  
  <p><a href="https://i.stack.imgur.com/3K6A9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3K6A9.png" alt="enter image description here"></a></p>
  
  <p>I am not able to understand what error I am doing and why time is starting from 22:00 and OHLC candles are not visible.</p>
  
  <p>If you can also help with volume overlay on ohlc chart it would be a great help.<a href="https://drive.google.com/file/d/0B4iD4lT8-7J2ckhNcFIxR0E3YTA/view?usp=sharing" rel="nofollow noreferrer">link to data file</a></p>
  
  <pre><code>from datetime import datetime, date, timedelta
  import matplotlib.pyplot as plt
  import matplotlib.dates as mdates
  import matplotlib.gridspec as grd
  from matplotlib.transforms import Bbox
  from matplotlib.finance import candlestick_ohlc, volume_overlay3, volume_overlay
  #from matplotlib.finance import candlestick
  from matplotlib.backends.backend_pdf import PdfPages
  from matplotlib.dates import DateFormatter, WeekdayLocator, DayLocator, MONDAY, HourLocator, MinuteLocator
  
  
  import numpy as np
  import pandas as pd
  
  
  def plot_underlying_hft_data(filename):
  
  
      #Read the data and filtered out the required rows and columns
      print("Reading File.. ", filename)
      tempdata = pd.read_csv(filename, index_col = ['Date'])
      tempdata = tempdata.loc[(tempdata.index == '2016-09-16')]
  
      tempdata['Datetime'] =  pd.to_datetime(tempdata['Datetime'], format='%Y-%m-%d %H:%M:%S')
      print(tempdata)
  
      HourLocator
  
      hour = HourLocator()    
      minute = MinuteLocator()
      hourformatter = DateFormatter('%H:%M') 
  
      #tempdata['Datetime'] = tempdata['Datetime'].apply(lambda datetimevar : datetime)
  
      tempdata['DatetimeNum'] = mdates.date2num(tempdata['Datetime'].dt.to_pydatetime())
  
      quotes = [tuple(x) for x in tempdata[['DatetimeNum', 'Open', 'High', 'Low', 'Close', 'Volume']].to_records(index=False)]
  
      #print(quotes)    
      title_name_ohlc = 'OHLC Intraday Chart'
      #print(title_name_ohlc)
      plt.figure(figsize = (12,6))
      #plt.title(title_name_ohlc)
      ax1 = plt.subplot2grid((1,1), (0,0), axisbg='w')
  
      ax1.set_ylabel('Price', fontsize=12, fontweight = 'bold')
      ax1.set_title(title_name_ohlc, fontsize=14, fontweight = 'bold')
      ax1.set_ylabel('Price', fontsize=12, fontweight = 'bold')
      ax1.set_title(title_name_ohlc, fontsize=14, fontweight = 'bold')
      print(tempdata['DatetimeNum'].min(), tempdata['DatetimeNum'].max())
      ax1.set_ylim(bottom = tempdata['DatetimeNum'].min(), top = tempdata['DatetimeNum'].max())
  
      ax1.xaxis.set_major_locator(hour)
      ax1.xaxis.set_minor_locator(minute)
      ax1.xaxis.set_major_formatter(hourformatter)
      #ax1.grid(True)
      candlestick_ohlc(ax1, quotes, width=1, colorup='g', colordown='r', alpha = 1.0)
      plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')
      plt.show()
  
  plot_underlying_hft_data("data.csv")
  
          #print(tempdata.head(5))
  </code></pre>