Skip to content

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

@megies

Description

@megies

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()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions