Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Errorbar plot on log-scaled Axes sets incorrect automatic lower limits #31462

@nj-vs-vh

Description

@nj-vs-vh

Bug summary

I'm plotting some log-scale data with ax.errorbar. If I plot first and then call ax.set_[x/y]scale, autolimits work as expected. However, switching the order (first setting the scale, then plotting the errorbars) leads to incorrect autolimits.

Code for reproduction

import numpy as np
from matplotlib import pyplot as plt

x = 10 ** np.array([18, 18.1, 18.2, 18.3])
y = np.array([100, 80, 60, 30])
yerr = np.ones_like(y) * 10

fig, ax = plt.subplots()
ax.set_xscale("log")
ax.set_yscale("log")
ax.errorbar(x, y, yerr=yerr)

fig.savefig("test.png")

Actual outcome

Both x and y axes have lower limits at 1. Upper limits seem correct.

Image

Expected outcome

If I call set_*scale after plotting, everything works as expected:

Image

The same plot should be produced by the MRE script above.

Additional information

No response

Operating system

Ubuntu

Matplotlib Version

3.10.8, also occurred on 3.10.5

Matplotlib Backend

agg

Python version

3.13.7

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions