title: shifted errorbar plot wrt hist plot
body: <p>Could someone help me figure out as to why error bars are shifted a bit as compared to line histogram? I wish to have error bars at the center of each bar of line histogram.</p>
  
  <pre><code>#mc and data are two dataframes.
  norm = np.empty_like(mc['variable'])
  bins=np.linspace(0,30,101)
  binw=bins[1]-bins[0]
  xc = bins[1:]-binw*0.5
  
  hist_mc_corr,_ = np.histogram(mc['variable'].values, density=False, weights=mc['weight_mc'].values, bins=bins) 
  hist_data,_ =  np.histogram(data['variable'].values, density=False, weights=data['weight_data'].values, bins=bins)
  
  norm.fill(hist_data.sum()/hist_mc_corr.sum() )
  
  plt.hist(mc['variable'], bins=100, range=(0, 30),histtype='step', weights=norm*mc['weight_mc'],)
  (_, caps, _) = plt.errorbar(xc+binw*0.5, hist_data,ls='None', yerr=np.sqrt(hist_data), xerr=np.ones_like(hist_data)*binw*0.5,  
   color='black', label='data', marker='.')
  for cap in caps:
      cap.set_markeredgewidth(0)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/00Obi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/00Obi.png" alt="enter image description here"></a></p>
  
  <p>While it should look like (except I do not want to fill histogram with color.)</p>
  
  <p><a href="https://i.stack.imgur.com/0vmbi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0vmbi.png" alt="enter image description here"></a></p>
  
  <p>Many thanks!</p>