Setting Custom axis values pyplot
matplotlib, python, python-2.7, tkinter
Solution
ax.set_xticks(ticks=[0,2,4,5,30,50])
Discovered this after messing with my code some more.
Problem
I have a plot in a tkinter.Toplevel window and I would like to have it use a custom spaced x-axis. Currently it is set as default so the numbers are evenly spaced (0,5,10,15... etc.). I would like to have a tick mark for each data point I have (example 2,6,15,30). I am sure it is just some key word under some header, but I cannot figure out which one it is. Below is an example of the code that it would be going into. ``` import matplotlib matplotlib.use('TkAgg') from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg from matplotlib.figure import Figure import Tkinter as tk root = tk.Toplevel(width=2000) f = Figure() ax = f.add_subplot(111) zeroy = [0,25] zerox = [0, 35] p3 = ax.plot(zerox, zeroy, 'k-') canvas = FigureCanvasTkAgg(f, master=root) canvas.show() canvas.get_tk_widget().grid(row=0) toolbar = NavigationToolbar2TkAgg(canvas, root) toolbar.grid(row=1, sticky=tk.W) toolbar.update() button = tk.Button(root, text='Quit', command = root.destroy) button.grid(row=2) root.mainloop() ``` I have tried to use `ax.xticks(...)` and `f.add_axes(xticks=[1,2,5,7]` but these didn't work. I have also tried a variety of other weak attempts without success. Any help would be appreciated. Thanks.