Skip to content

plot_date() after axhline() doesn't rescale axes #7742

Closed
@dstansby

Description

@dstansby

If I plot an axhline first, and then two points with plot_date, the x-axis is not rescaled to the two new data points:

import matplotlib.pyplot as plt
from datetime import datetime

fig, axs = plt.subplots(2, 1)

axs[0].axhline(1.5)
axs[0].plot([datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)], [1, 2])

axs[1].plot([datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)], [1, 2])
axs[1].axhline(1.5)

plt.show()

figure_1-1

I would expect the two plots to be the same, and the plotting order not to matter.

Present on current master (2.0.0rc2.post2912+g015d8d5) and on 1.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions