adding a "number of minor tick marks between major tick marks" feature

Matplotlib developers,

I really like using matplotlib to create quality plots, and it seems to have an option for just about everything. However, one thing that is not easy to change is the location of minor tick marks. To set major tick mark locations, one can simply use the "xticks" command. And now we can atleast turn on the minor tick marks with the "minorticks_on()" command.

But, is there any way to implement something similar to "xticks" for minor tick marks? Even better would be a feature that allowed the user to simply specify the number of minor tick marks that are evenly spaced between the major tick marks?

Thanks.

--Matthew

Hi Matthew,

one thing, which should work is the following. If you want to set the
positions of minor ticks of an axes 'ax', you can use

ax.set_xticks([0.02, 0.04, 0.06, 0.08, 0.1], minor=True)

but I'm not an expert and I'm not sure if something like you mentioned is
already supported (namely providing the number of minor tick marks).

Kind regards,
Matthias

···

On Monday November 29 2010 22:01:29 Matthew W. Priddy wrote:

Matplotlib developers,

I really like using matplotlib to create quality plots, and it seems to
have an option for just about everything. However, one thing that is not
easy to change is the location of minor tick marks. To set major tick
mark locations, one can simply use the "xticks" command. And now we can
atleast turn on the minor tick marks with the "minorticks_on()" command.

But, is there any way to implement something similar to "xticks" for minor
tick marks? Even better would be a feature that allowed the user to
simply specify the number of minor tick marks that are evenly spaced
between the major tick marks?

It is easy with MultipleLocator class.

I[1]: y = np.random.randn(100)

I[2]: plt.plot(y)
O[2]: [<matplotlib.lines.Line2D object at 0xa82ea6c>]

I[3]: from matplotlib.ticker import MultipleLocator

I[4]: ax = plt.gca()

I[5]: ax.xaxis.set_minor_locator(MultipleLocator(5))

···

On Mon, Nov 29, 2010 at 3:01 PM, Matthew W. Priddy <mwpriddy@...287...> wrote:

Matplotlib developers,

I really like using matplotlib to create quality plots, and it seems to have an option for just about everything. However, one thing that is not easy to change is the location of minor tick marks. To set major tick mark locations, one can simply use the "xticks" command. And now we can atleast turn on the minor tick marks with the "minorticks_on()" command.

But, is there any way to implement something similar to "xticks" for minor tick marks? Even better would be a feature that allowed the user to simply specify the number of minor tick marks that are evenly spaced between the major tick marks?

Thanks.

--Matthew

--
Gökhan