Source: matplotlib
Version: 3.6.2-3
Severity: serious
Justification: debci
Control: forwarded -1 https://github.com/matplotlib/matplotlib/issues/24842
Control: block 1027170 by -1

mplot3d.axes3d.quiver() accepts boths args and kwargs in its function
definition.

Both args (any remaining after the first 6 values) and kwargs are
passed onwards to art3d.Line3DCollection at
matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py Line 2655 in 3393a4f:

  linec = art3d.Line3DCollection(lines, *args[argi:], **kwargs) 

But arguments for Line3DCollection are passed directly to
LineCollection. In matplotlib PR#23076 appearing in matplotlib 3.6,
LineCollection was changed so that it no longer accepts positional
args. All excess arguments must now be provided in kwargs.

This means axes3d.quiver() now fails with matplotlib 3.6. An example
failure is in 3D plot tests from dolfin.

The python backtrace running* this demo script (on a debian system)
looks like

Traceback (most recent call last):
  File 
"/projects/fenics/build/tests/dolfin/demo-python/undocumented/curl-curl/demo_curl-curl.py",
 line 172, in <module>
    plot(J)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/common/plotting.py", 
line 440, in plot
    return _plot_matplotlib(object, mesh, kwargs)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/common/plotting.py", 
line 306, in _plot_matplotlib
    return mplot_function(ax, obj, **kwargs)
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/common/plotting.py", 
line 218, in mplot_function
    return ax.quiver3D(*args, length=length, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 1427, in 
inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/axes3d.py", line 
2567, in quiver
    linec = art3d.Line3DCollection(lines, *args[argi:], **kwargs)
TypeError: LineCollection.__init__() takes 2 positional arguments but 3 were 
given

The TypeError occurs because of the use of args, which, to reiterate,
was removed in matplotlib 3.6 PR#23076.

I gather that any options which were previously provided to
axes3d.quiver and intended for use in Line3DCollection must now be
provided in kwargs instead. quiver should no longer use args at all at
l.2655.


* Note, to run that dolfin demo to reproduce the error,
dolfin/common/plotting.py also needed updating for matplotlib 3.6 near
l.279:
-        ax = plt.gca(projection='3d')
+        ax = plt.axes(projection='3d')
This patch will be applied to dolfin to close Bug#1027170.


For matplotlib itself, I propose simply removing the use of args in
axes3d.py l.2655:

-  linec = art3d.Line3DCollection(lines, *args[argi:], **kwargs) 
+  linec = art3d.Line3DCollection(lines, **kwargs) 

Reply via email to