Description
Bug summary
It is impossible to create a new Matplotlib.lines.AxLine
artist because the constructor cannot be satisfied
Code for reproduction
import matplotlib.lines as lines
# first attempt
my_first_line = lines.AxLine(xy1=(0, 0), xy2=(1, 1))
# second attempt
my_second_line = lines.AxLine(xy1=(0, 0), slope=1)
#third attempt
my_third_line = lines.AxLine(xy1=(0, 0), xy2=(1, 1), slope=1)
Actual outcome
first attempt:
TypeError: AxLine.__init__() missing 1 required positional argument: 'slope'
second attempt:
TypeError: AxLine.__init__() missing 1 required positional argument: 'xy2'
third attempt:
TypeError: Exactly one of 'xy2' and 'slope' must be given
Expected outcome
The first and second attempt should create and return AxLine objects. Only the third attempt should raise an exception
Additional information
The constructor for AxLine does not provide default values for either 'xy2' or 'slope', which makes both required, resulting in the errors in attempts 1 and 2.
Suggested fix:
default both xy2 and slope to None
.
Operating system
No response
Matplotlib Version
3.8.2
Matplotlib Backend
No response
Python version
3.12.1
Jupyter version
No response
Installation
pip