title: Embedding matplotlib chart using FigureCanvasTkAgg - set xticks
body: <p>I am creating a GUI which includes a variety of embedded charts. I am using <strong>matplotlib</strong> and <strong>FigureCanvasTkAgg</strong> with <strong>tkinter</strong> to do so and everything is working fine apart from the x axis labels. I can easily set the labels using <strong>plt.xticks</strong> when creating a matplotlib chart that appears in a new window but not when using <strong>FigureCanvasTkAgg</strong>.</p>
  
  <p>I have not included my full code as it is far too long, but I have included all the code I think is relevant (pyplot is used elsewhere but should not be relevant to my problem). The <strong>chart.set_xticks</strong> here does not actually do anything: instead of showing the labels in the list titled <strong>objects</strong>, it shows 0 then goes up in integers with every other data point actually labelled as per the image below. I have tried various different things using <strong>chart.set_xticks</strong>, but can only remove all labels using <strong>chart.set_xticks([])</strong> or specify integers using <strong>chart.set_xticks([0,1,2,3...])</strong> which labels each data point but not with the labels I require.</p>
  
  <p>Any ideas?</p>
  
  <p><img src="https://i.stack.imgur.com/35t9A.png" alt="Bar chart without correct x labels"></p>
  
  <pre><code>import matplotlib.pyplot as plt
  import matplotlib
  matplotlib.use("TkAgg")
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  from matplotlib.figure import Figure
  
  objects = ["2x", "3x", "4x", "5x", "6x", "7x", "8x", "9x", "10x", "11x", "12x", "Year 2", "Year 3", "Year 4"]    
  y_pos = np.arange(len(objects))
  
  fig = Figure(figsize=(font * 8, font * 5))
  
  chart = fig.add_subplot(111)
  chart.set_ylim(ymin=0, ymax=32)
  chart.bar(y_pos, plotList, color=colours, alpha=0.5, label="Table")
  chart.bar(y_pos, inversePlotList, color=colours, label="Inverse")
  chart.set_xticks(y_pos, objects)
  chart.set_ylabel("Average score")
  chart.legend()
  
  canvas = FigureCanvasTkAgg(fig, master=userTablesFrame)
  canvas.get_tk_widget().place(relx=0.5, rely=0.5, anchor=CENTER)
  canvas.draw()
  </code></pre>