Skip to content

Drops last tick label for some ranges #1310

Closed

Description

@tacaswell

For some values (related to multiples of .3 and .7 it seems) drop the last tick label.

expected: the last tick to be labeled, spacing of .1 between major ticks
get: all be last label are correct

The following demonstration is assumed to be in an interactive shell with pylab imported

fig = figure()
ax = gca()
draw()
ax.get_yaxis().set_major_locator(matplotlib.ticker.MultipleLocator(0.1))
ax.set_ylim([0,.2]); draw() # works
ax.set_ylim([0,.3]); draw() # fail
ax.set_ylim([0,.4]); draw() # works
ax.set_ylim([0,.6]); draw() # fail
ax.set_ylim([0,.7]); draw() # fail
ax.set_ylim([0,1.2]); draw() # fail
ax.set_ylim([0,1.4]); draw() # fail

tested against master branch.

In [17]: matplotlib.version
Out[17]: '1.2.0rc2'

using QT4Agg with PyQT4

Activity

  1. WeatherGod commented on Sep 26, 2012

    @WeatherGod
    Member

    Confirmed. It looks like it is a floating-point issue. Observe:

    >>> 2 * 0.1
    0.2
    >>> 3 * 0.1
    0.30000000000000004
    >>> 4 * 0.1
    0.4
    >>> 7 * 0.1
    0.7000000000000001
    
  2. tacaswell commented on Jan 12, 2013

    @tacaswell
    MemberAuthor

    One way to fix this is to launder the maximum value through float(str(val)), but that seems super hacky.

  3. mdboom commented on Jan 14, 2013

    @mdboom
    Member

    Sorry I'm just noticing this issue now -- it's a pretty serious one. @tacaswell: Can you file a PR with this commit (or is it already part of another PR)?

  4. tacaswell commented on Jan 14, 2013

    @tacaswell
    MemberAuthor

    @mdboom I didn't put in a PR before because I was not sure of it was too hackish a fix.

  5. tacaswell commented on Apr 9, 2013

    @tacaswell
    MemberAuthor

    #1686 was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions