Problem with tick locater

Hello,

Considering this example plot: http://imageshack.us/photo/my-images/27/imagefki.png/

How can I get the minor ticks showing correctly? (ie., 9 minor ticks per decade likewise for the x-axis)

For some reason

axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired output.

Any hints?

Thanks.

···


Gökhan

By default, setting the scale to log (e.g., ax.set_yscale(‘log’)) should automatically turn the minor ticks on for you. Note that depending on your version of mpl, there may be a slight error in the documentation for LogLocator.

Ben Root

···

On Fri, Sep 23, 2011 at 2:07 PM, Gökhan Sever <gokhansever@…287…> wrote:

Hello,

Considering this example plot: http://imageshack.us/photo/my-images/27/imagefki.png/

How can I get the minor ticks showing correctly? (ie., 9 minor ticks per decade likewise for the x-axis)

For some reason

axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired output.

Any hints?

Thanks.


Gökhan

Hi,

I set the log scales for both axes. However, as you see in the image y-axis has only 4 minor ticks (8 expected) where as x-axis has none. I am using a couple days old mpl build.

···

On Fri, Sep 23, 2011 at 1:22 PM, Benjamin Root <ben.root@…120…1304…> wrote:

On Fri, Sep 23, 2011 at 2:07 PM, Gökhan Sever <gokhansever@…287…> wrote:

Hello,

Considering this example plot: http://imageshack.us/photo/my-images/27/imagefki.png/

How can I get the minor ticks showing correctly? (ie., 9 minor ticks per decade likewise for the x-axis)

For some reason

axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired output.

Any hints?

Thanks.


Gökhan

By default, setting the scale to log (e.g., ax.set_yscale(‘log’)) should automatically turn the minor ticks on for you. Note that depending on your version of mpl, there may be a slight error in the documentation for LogLocator.

Ben Root


Gökhan

I guess I would have to see your code. The y-axis ticks works fine in the examples:

http://matplotlib.sourceforge.net/examples/pylab_examples/log_demo.html

Viewing the pdf or hires png shows 8 minor ticks.

Now, as for the x-axis, there are no minor ticks. That might be an issue…

Ben Root

···

On Fri, Sep 23, 2011 at 2:28 PM, Gökhan Sever <gokhansever@…287…> wrote:

On Fri, Sep 23, 2011 at 1:22 PM, Benjamin Root <ben.root@…1304…> wrote:

On Fri, Sep 23, 2011 at 2:07 PM, Gökhan Sever <gokhansever@…287…> wrote:

Hello,

Considering this example plot: http://imageshack.us/photo/my-images/27/imagefki.png/

How can I get the minor ticks showing correctly? (ie., 9 minor ticks per decade likewise for the x-axis)

For some reason

axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired output.

Any hints?

Thanks.


Gökhan

By default, setting the scale to log (e.g., ax.set_yscale(‘log’)) should automatically turn the minor ticks on for you. Note that depending on your version of mpl, there may be a slight error in the documentation for LogLocator.

Ben Root

Hi,

I set the log scales for both axes. However, as you see in the image y-axis has only 4 minor ticks (8 expected) where as x-axis has none. I am using a couple days old mpl build.

Hi,

Another question is, what sets the tick-location on a log scaled axis? (that 10^-5, 10^-3, 10^-1, 10^1) It seems as if the range is greater than certain value ticks are located this way. Also in a similar way, the location of minor ticks are decided. (If the range is big, no minor ticks, if the range is not too big, put 4 minor ticks --which is very inconvenient to eye, if range is small then nicely locate 9 minor ticks.)

Hah, the next probably will be manually forcing the _ticks or ticklocator functions.

Anyone else experiencing similar behavior in mpl?

···

On Fri, Sep 23, 2011 at 1:07 PM, Gökhan Sever <gokhansever@…287…> wrote:

Hello,

Considering this example plot: http://imageshack.us/photo/my-images/27/imagefki.png/

How can I get the minor ticks showing correctly? (ie., 9 minor ticks per decade likewise for the x-axis)

For some reason

axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired output.

Any hints?

Thanks.


Gökhan


Gökhan

OK,

This fixes the minor locations on y-axis

ax1.yaxis.set_minor_locator(ticker.LogLocator(subs=np.arange(2.0, 10.0)))

Independent of the data-range. It seems like ticker.LogLocator is trying to adjust the minor locs internally.

···

On Fri, Sep 23, 2011 at 7:18 PM, Gökhan Sever <gokhansever@…287…> wrote:

Hi,

Another question is, what sets the tick-location on a log scaled axis? (that 10^-5, 10^-3, 10^-1, 10^1) It seems as if the range is greater than certain value ticks are located this way. Also in a similar way, the location of minor ticks are decided. (If the range is big, no minor ticks, if the range is not too big, put 4 minor ticks --which is very inconvenient to eye, if range is small then nicely locate 9 minor ticks.)

Hah, the next probably will be manually forcing the _ticks or ticklocator functions.

Anyone else experiencing similar behavior in mpl?

On Fri, Sep 23, 2011 at 1:07 PM, Gökhan Sever <gokhansever@…1972…> wrote:

Hello,

Considering this example plot: http://imageshack.us/photo/my-images/27/imagefki.png/

How can I get the minor ticks showing correctly? (ie., 9 minor ticks per decade likewise for the x-axis)

For some reason

axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired output.

Any hints?

Thanks.


Gökhan


Gökhan


Gökhan

One more update, before heading to the bed.

I have managed to adjust my ticks to get what I was asking originally. See the code at http://pastebin.com/XjkDZ486

1-) ax1.yaxis.set_minor_locator(ticker.LogLocator(subs=np.arange(2.0, 10.0)))

with this line I can get the desired number of minor ticks at the correct positions

2-) #ax1.xaxis.set_ticks(10.**np.arange(np.log10(xmin),np.log10(xmax)+1,1))

this line puts major at every decade but minors aren’t printed correctly due to striding at major ticks.

3-) To get this one working I needed to modify the code within the ticker.LogLocator()

particularly the two lines starting at https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/ticker.py#L1311

decades = np.arange(math.floor(vmin),

math.ceil(vmax)+stride, stride)

edited to

decades = np.arange(math.floor(vmin),

math.ceil(vmax)+1, 1)

previously I was getting a major tick at every other decade. With this change I get a major tick at every decade plus the minor ticks look nicer. So my opinion is this stride should be parameter to the LogLocator(), so based on what people wants to plot it can be easily adjusted.

Any comments/other solutions?

Thanks.

···

On Fri, Sep 23, 2011 at 10:47 PM, Gökhan Sever <gokhansever@…287…> wrote:

OK,

This fixes the minor locations on y-axis

ax1.yaxis.set_minor_locator(ticker.LogLocator(subs=np.arange(2.0, 10.0)))

Independent of the data-range. It seems like ticker.LogLocator is trying to adjust the minor locs internally.

On Fri, Sep 23, 2011 at 7:18 PM, Gökhan Sever <gokhansever@…287…> wrote:

Hi,

Another question is, what sets the tick-location on a log scaled axis? (that 10^-5, 10^-3, 10^-1, 10^1) It seems as if the range is greater than certain value ticks are located this way. Also in a similar way, the location of minor ticks are decided. (If the range is big, no minor ticks, if the range is not too big, put 4 minor ticks --which is very inconvenient to eye, if range is small then nicely locate 9 minor ticks.)

Hah, the next probably will be manually forcing the _ticks or ticklocator functions.

Anyone else experiencing similar behavior in mpl?

On Fri, Sep 23, 2011 at 1:07 PM, Gökhan Sever <gokhansever@…1972…> wrote:

Hello,

Considering this example plot: http://imageshack.us/photo/my-images/27/imagefki.png/

How can I get the minor ticks showing correctly? (ie., 9 minor ticks per decade likewise for the x-axis)

For some reason

axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired output.

Any hints?

Thanks.


Gökhan


Gökhan


Gökhan


Gökhan