title: How to set the xtick position for secondary axis in matplotlib?
body: <p>I want to create a secondary xaxis at the top which has an inverse relation with the major xaxis at the bottom. I followed the official tutorial <a href="https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/secondary_axis.html" rel="nofollow noreferrer">here</a> and have the following codes:</p>
  
  <pre><code>def forward(x):
      return 10/x
  
  def backward(y):
      return 10/y
  
  fig, ax = plt.subplots()
  ax.set_xlim([0.14, 1.4])
  secax = ax.secondary_xaxis('top', functions=(forward, backward))
  secax.set_xticks(np.array([10,20,40,70]))  # does not work!
  plt.show()
  </code></pre>
  
  <p>The problem is that the xticks at the top are not at the right place. They are bunched together in the left due to the inverse function applied. How do I manually set the position of the xticks? (e.g. at 10,20,40,70)</p>
  
  <p>Edit:
  Just to make it more clear, the ticks are at the right place, but there are too many tickss as shown in the figure. In this case, I only want the ticks at 10, 20, 40, 70 (I don't want the ticks at 30, 50 and 60 as we can't see all the tick numbers clearly)
  <a href="https://i.stack.imgur.com/FYes0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FYes0.png" alt="enter image description here"></a></p>