FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Locators: First visible tick does not have `pos=0` · Issue #2509 · matplotlib/matplotlib · GitHub

Repository navigation

Locators: First visible tick does not have pos=0 #2509

Closed

Description

I noticed that various Locators have problems designating pos=0 to the first visible tick. While this might not be very important for most people, I still thought I'd mention it here.

For AutoDateLocator this happens below a certain threshold of x range. Below an x range of around 5e-5 (equal to approximately 5 seconds) the tick with position 0 is not inside the plot anymore.
I admit that this is a rather low value for date plots and thus might be considered very low priority.

For AutoLocator this seems to be a general problem. Almost always the first visible tick has position 1.

The following script demonstrates both cases. Zoom in/out on x axes and look at pos of the first tick.

import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
from numpy.random import randn


def print_pos(x, pos=None):
    return "%s: %s" % (str(pos), str(x))


fig = plt.figure(figsize=(16, 6))
fig.suptitle("xticklabels are 'pos: x'")

ax = fig.add_subplot(211)
left = 10
right = left + 6e-5
ax.plot_date([left, right], [1, 1])
ax.xaxis.set_major_formatter(FuncFormatter(print_pos))
ax.set_title("zoom in: leftmost tick has position 1")

ax = fig.add_subplot(212)
ax.plot(randn(20), randn(20))
ax.xaxis.set_major_formatter(FuncFormatter(print_pos))
ax.set_title("zoom in/out: leftmost tick has position 1")

plt.show()

Activity

  1. tacaswell commented on Feb 27, 2014

    Member

    punting this to 1.5 as I am not clear why this is a problem and will probably involve a re-write of the AutoLocator family.

  2. modified the milestones: , v1.4.0 on Feb 27, 2014
  3. efiring commented on Feb 27, 2014

    Member

    The pos is assigned in the Axis.iter_ticks() method, before a final decision is made on which ticks will actually be drawn, which is in the Axis._update_ticks() method. The tick handling code is very complex.

  4. modified the milestones: , on Nov 26, 2014
  5. tacaswell commented on Nov 26, 2014

    Member

    Closing as this seems to be an intentional part of the design and pos is on implementation detail that should not be leaking out to userland.

  6. tacaswell commented on Nov 26, 2014

    Member

    @megies If you disagree, please ping me and we can re-open this.

  7. megies commented on Nov 27, 2014

    ContributorAuthor

    pos is on implementation detail that should not be leaking out to userland.

    Well, when implementing a FuncFormatter it is one of two pieces of information that the user can work with, so I would tend to disagree that it's "inadvertently leaking out".

    But, yeah, might not be super important, so it can stay closed, I guess.

  8. added a commit that references this issue on Oct 3, 2024
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


      Back | FazBrowse Home | New Git URL