title: How to (re)scale the x-axis to fit certain points in the graph?
body: <p>I want to rescale my (qualitative) x-axis so the two peaks (visible in the graph) correlate to their actual values (i. e. 500 keV and 1274 MeV).
  How can I do this?</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  def read_from_file(filename):
      return np.loadtxt(filename)
  
  data = list(read_from_file("calibration.txt"))
  
  print(data.index(max(data[:2000])))#x value 500kev
  print(data.index(max(data[2000:])))#x value 1274
  
  fig = plt.figure()
  ax = fig.add_subplot(111)
  x = range(len(data))
  plt.plot(x, data)
  plt.xlim(0, 5000)
  plt.ylim(0, 7000)
  plt.title("$^{22}$Na Spectrum")
  plt.xlabel("Energy")
  plt.ylabel("Amount of Photons")
  plt.grid()
  ax.annotate("500 keV", xy = (1450, 6541), xytext = (1600, 6500))
  ax.annotate("1274 MeV", xy = (3500, 950), xytext = (3700, 1100))
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zcLBU.png" alt="enter image description here"></p>