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

Skip to content

[Bug]: Bad type hint in _AxesBase.twinx() #28624

Closed
@randolf-scholz

Description

@randolf-scholz

Bug summary

Incorrect type annotation for _AxesBase.twinx() (should be Self, not _AxesBase).

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

# First create some toy data:
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x**2)
z = np.cos(x**2)

# Create four polar Axes and access them through the returned array
fig, axsA = plt.subplots()
axsA.plot(x, y)
axsB = axsA.twinx()
axsB.plot(x, z)  # <-- Cannot access attribute "plot" for class "_AxesBase"

Actual outcome

axsB is of type _AxesBase

Expected outcome

The type of axsB should be the same as the type of axsA.

Matplotlib Version

3.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions