title: Matplotlib Xticks Confusion
body: <p>I want to create a bar chart using matplotlib for two target groups: Sale '1' and not Sale '0'. My data:</p>
  
  <pre><code>Sale     item                 Count
  0        1.0                   3520
           2.0                      9
           3.0                   2095
           4.0                    586
           5.0                    609
           6.0                    427
           7.0                    101
           8.0                    111
  1        1.0                     88
           3.0                     43
           4.0                     28
           5.0                     36
           6.0                     16
           7.0                      3
           8.0                      4
  </code></pre>
  
  <p>The current code:</p>
  
  <pre><code>fig, ax = plt.subplots(figsize=(10,4))
  labels=['1.0','2.0','3.0','4.0', '5.0', '6.0', '7.0', '8.0']
  itemSale0 = X_train[X_train.hasSale==0]
  itemSale0=itemSale0.groupby('item').size().values
  x = np.arange(len(labels))  # the label locations
  width = 0.35  # the width of the bars
  rects1=ax.bar(x - width/2, itemSale0, width, label='Not Sale')
  
  labels=['1.0','3.0','4.0', '5.0', '6.0', '7.0', '8.0']
  itemSale1 = X_train[X_train.hasSale==1]
  itemSale1 = itemSale1.groupby('item').size().values    
  x = np.arange(len(labels))  # the label locations
  width = 0.35  # the width of the bars
  rects2=ax.bar(x + width/2, itemSale1, width, label='Sale')
  
  # Add some text for labels, title and custom x-axis tick labels, etc.
  ax.set_ylabel('Count')
  ax.set_title('Sale by Traffice Source')
  ax.set_xticks(x)
  ax.set_xticklabels(labels)
  ax.legend()
  
  def autolabel(rects):
      """Attach a text label above each bar in *rects*, displaying its height."""
      for rect in rects:
          height = rect.get_height()
          ax.annotate('{}'.format(height),
                      xy=(rect.get_x() + rect.get_width() / 2, height),
                      xytext=(0, 3),  # 3 points vertical offset
                      textcoords="offset points",
                      ha='center', va='bottom')
  
  
  autolabel(rects1)
  autolabel(rects2)
  </code></pre>
  
  <p>Problem : items where sale is '0' are 1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0 does not match to the item numbers where sale exist '1' are 1.0,3.0,4.0, 5.0,6.0,7.0,8.0 in graph xticks. </p>
  
  <pre><code>items where sale is not are 1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0 
  items where sale are        1.0,   ,3.0,4.0,5.0,6.0,7.0,8.0
  </code></pre>
  
  <p>Both are overlapping please see attached screen,it cannot distinguish at item 2.0 where 9 items are not sold and its bar has merged to xticks item 3 where 43 items sold, how can I show xticks which can separate both items 2.0 for not sale 9 and 3.0 for sale 43 items</p>
  
  <p><img src="https://i.stack.imgur.com/WgsNJ.png" alt="enter image description here"></p>