title: Changing xticks for one subplot with shared x axis
body: <p>I want to change xlimits and xticks in one subplot of many subplots, but it only works for xticks.</p>
  
  <p>I am plotting many plots, and almost all of them have the same x axis, in one figure and therefore have decided to use <code>plt.subplots(sharex=True)</code>. For one plot I want different limits and ticks on my x axis. To do this, I remove this plot from the other sharex plots with <code>ax.get_shared_x_axes().remove(ax)</code>.</p>
  
  <pre class="lang-py prettyprint-override"><code>
  import matplotlib.pyplot as plt
  fig, axes = plt.subplots(4,10,sharey=True, sharex=True)
  
  axes_flat = axes.flat
  
  for i in range(0,33) :
     xs = axes_flat[i]
     xs.plot([0,1,2],[2,3,4])
     xs.set_xticks([0,2])
     xs.set_xlim([0,4])
  
  
  #leave some room between normal plots and plots with different xlims:
  axes_flat[34].axis('off')
  axes_flat[35].axis('off')
  
  # Remove this plot from the shared axes and change xlims and xticks:
  axes_flat[36].get_shared_x_axes().remove(axes_flat[36])
  axes_flat[36].set_xticks([0,1])
  axes_flat[36].set_xlim([0,2])
  
  axes_flat[38].axis('off')
  axes_flat[39].axis('off')
  
  plt.show()
  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YVh0V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YVh0V.png" alt="enter image description here"></a></p>
  
  <p>This works as expected for the x limits but not for the xticks. Changing the ticks in one subplot overwrites all the other ticks, while the x limits are only changed in the subplot, which I wanted to. I do not understand why <code>set_xticks</code> and <code>set_xlim</code> would behave differently in this case. Is there a way to fix this, while still using  <code>plt.subplots(sharex=True)</code> ?</p>