semilog minor grid problem

I cannot seem to get the following code produce what I expect. I want minor tick marks between my major ticks on a base 2 logx plot.

ax = axes()

ax.set_xlim(0.5, 2)

ax.set_xscale(‘log’, basex=2, subsx=range(2,9))

grid(b=True, which=‘minor’)

I would have expected there to be minor ticks at 2^(-1:0.1:1) excluding -1,0 and 1. Any help would be appreciated.

Kind regards,

Kurt

Kurt,

That `subsx` kwarg is tricky. Does this example get you closer to what you
want?

import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set_xlim(0.5, 10)
ax.set_xscale('log', basex=2, subsx=np.arange(1.,2.1,0.1))
ax.xaxis.grid(True, which='minor')
plt.show()

-paul

···

On Wed, Dec 12, 2012 at 7:55 AM, Forrester, Kurt < kurt.forrester.fec@...287...> wrote:

ax.set_xlim(0.5, 2)
ax.set_xscale('log', basex=2, subsx=range(2,9))

Thank you Paul. That is exactly it. I guess I was confused by the example in the help. The addition of your example would be a great addition to the help file.

Kurt

···

On 12 December 2012 23:56, Paul Hobson <pmhobson@…287…> wrote:

On Wed, Dec 12, 2012 at 7:55 AM, Forrester, Kurt <kurt.forrester.fec@…287…> wrote:

ax.set_xlim(0.5, 2)

ax.set_xscale(‘log’, basex=2, subsx=range(2,9))

Kurt,

That `subsx` kwarg is tricky. Does this example get you closer to what you want?

import numpy as np

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax.set_xlim(0.5, 10)

ax.set_xscale(‘log’, basex=2, subsx=np.arange(1.,2.1,0.1))

ax.xaxis.grid(True, which=‘minor’)

plt.show()

-paul