[SciPy-User] [matplotlib] xgrid on values of x-variable?

Klonuo Umom klonuo at gmail.com
Tue Jun 7 06:34:11 EDT 2011


On 07.06.2011 12:20:16 Scott Sinclair wrote:

> On 7 June 2011 11:32, Klonuo Umom <klonuo at gmail.com> wrote:
> > I have very simple XY graph, and I want to display X grid only, and only
> > on values of X variable, which are lets say [10, 11, 12, 15, 20]
> 
> This is a question for the Matplotlib list
> (https://lists.sourceforge.net/lists/listinfo/matplotlib-users).


Yeah I know, sorry
I couldn't find how to register on SF mailing list, but nevermind -
problem solved :)

> 
> In any case, this should do what you want:
> 
> import numpy as np
> import matplotlib.pyplot as plt
> 
> fig = plt.figure()
> ax = fig.add_subplot(111)
> 
> ax.plot(range(5))
> 
> ticks = [1.2, 2.3, 3.1, 4]
> ax.xaxis.set_ticks(ticks)
> ax.xaxis.grid()
> 

So, ticks dictate the grid... Logically. Although I spent so much time
searching the manual and googling...

Thanks



More information about the SciPy-User mailing list