title: How to change spacing between ticks in matplotlib?
body: <p>I want to plot a graph with a lot of ticks on the X axis using the following code:</p>
  
  <pre><code>import pylab
  
  N = 100
  data = pylab.np.linspace(0, N, N)
  
  pylab.plot(data)
  
  pylab.xticks(range(N)) # add loads of ticks
  pylab.grid()
  pylab.tight_layout()
  pylab.show()
  
  pylab.close()
  </code></pre>
  
  <p>The resulting plot looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/sMNfD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sMNfD.png" alt="plot"></a></p>
  
  <p>As you can see, the X axis is a mess because the tick labels are plotted with too few space between them or even <em>overlap</em>.</p>
  
  <p>I would like to create constant space between each tick label automatically, no matter how many ticks there are. So, I'd like to increase the space between individual ticks, thus potentially increasing the 'length' of a plot.</p>
  
  <p>Note that the tick labels may be <em>strings of variable length</em>.</p>
  
  <p>What I have found so far is all about <a href="https://stackoverflow.com/questions/2969867/how-do-i-add-space-between-the-ticklabels-and-the-axes-in-matplotlib">spacing between the axis and labels</a> (which is not what I want), <a href="https://stackoverflow.com/questions/12608788/changing-the-tick-frequency-on-x-or-y-axis-in-matplotlib">tick frequency</a> (which I can already do) and <a href="https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.tick_params.html" rel="noreferrer">tick parameters</a> (which don't seem to have any options for spacing).</p>
  
  <p>I can change the size of a figure manually with <code>matplotlib.pyplot.figure(figsize=(a, b))</code>, but that would require knowledge of the default spacing between ticks (there's none, as far as I can tell) and the greatest width (in inches) of a tick label, which I have no clue how to measure, so this is not an option, to my mind.</p>
  
  <p>What can I do to increase spacing between ticks? I'm OK with getting a pretty lengthy image.</p>