Description
Bug summary
Calling add_lines on a horizontal colorbar is broken since commit 146856b
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib import colorbar
fig, ax = plt.subplots()
CS = ax.contour([[0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]])
cb = colorbar.Colorbar(ax, CS, orientation='horizontal')
cb.add_lines(CS)
Actual outcome
Traceback (most recent call last):
File "test.sage", line 5, in
cb = colorbar.Colorbar(ax, CS, orientation='horizontal')
File "/usr/lib/python3.9/site-packages/matplotlib/colorbar.py", line 496, in init
self.add_lines(mappable)
File "/usr/lib/python3.9/site-packages/matplotlib/colorbar.py", line 746, in add_lines
return self.add_lines(
File "/usr/lib/python3.9/site-packages/matplotlib/colorbar.py", line 788, in add_lines
col.set_clip_path(mpath.Path(xy, closed=True),
File "/usr/lib/python3.9/site-packages/matplotlib/path.py", line 130, in init
_api.check_shape((None, 2), vertices=vertices)
File "/usr/lib/python3.9/site-packages/matplotlib/_api/init.py", line 164, in check_shape
raise ValueError(
ValueError: 'vertices' must be 2D with shape (M, 2). Your input has shape (2, 5).
Expected outcome
No error
Additional information
No response
Operating system
Arch Linux
Matplotlib Version
3.5.0
Matplotlib Backend
QtAgg
Python version
3.9.7
Jupyter version
No response
Installation
from source (.tar.gz)