title: Hiding xticks labels every n-th label or on value on Pandas plot / make x-axis readable
body: <p><em>The question is pretty long because of the pictures, but there isn't much content in reality. Question at the bottom.</em></p>
  
  <p>Hi,
  I have a series of 30000 samples of ages ranging from 21 to 74.
  Series head:</p>
  
  <pre><code>0    24
  1    26
  2    34
  3    37
  4    57
  Name: AGE, dtype: int64
  </code></pre>
  
  <p>I plot it using built-in Pandas feature <code>.plot</code>:</p>
  
  <pre><code>age_series = original_df['AGE']
  fig = plt.figure()
  fig.suptitle('Age distribution')
  age_series.value_counts().sort_index().plot(kind='bar')
  </code></pre>
  
  <p>My problem is that it makes the x-axis not really user-friendly:
  <a href="https://i.stack.imgur.com/fS8CE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fS8CE.png" alt="Original plotting"></a></p>
  
  <p>I could increase the horizontal width between bars, but I don't want to do that. Instead, I'd like to make only a subset of the x-axis labels visible.
  I tried using <code>MaxNLocator</code> and <code>MultipleLocator</code> adding this line:</p>
  
  <pre><code>plt.gca().xaxis.set_major_locator(plt.MaxNLocator(10))
  </code></pre>
  
  <p>However, it doesn't achieve my goals, as it now incorrectly labels bars and removes ticks (which I understand since using these functions change the xticks object):
  <a href="https://i.stack.imgur.com/oHRDL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oHRDL.png" alt="MaxNLocator(10)"></a></p>
  
  <p>An ugly solution is to loop within the xticks object:</p>
  
  <pre><code>xticks = plt.gca().xaxis.get_major_ticks()
  for i in range(len(xticks)):
      if i % 10 != 0:
          xticks[i].set_visible(False)
  </code></pre>
  
  <p>Allowing this render, which is close to what I want:
  <a href="https://i.stack.imgur.com/XaA5P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XaA5P.png" alt="enter image description here"></a></p>
  
  <p>I'm not satisfied however, as the loop is too naive. I'd like to be able to access values from the xticks (the label) and make a decision upon it, to be able to show only multiple of 10 labels.</p>
  
  <p>This works (based upon <a href="https://stackoverflow.com/a/43734480/9571900">this answer</a>):</p>
  
  <pre><code>for i, l in enumerate(labels):
      val = int(l.get_text())
      if val % 10 != 0:
          labels[i] = ''
      plt.gca().set_xticklabels(labels)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IS1pD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IS1pD.png" alt="Ugly workaround"></a></p>
  
  <p><strong>Question: Is there any different solution, which feels more Pythonic/efficient ? Or do you have suggestions on how to make this data readable ?</strong></p>