Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: mplot3d
Milestone
Description
Code for reproduction
import matplotlib as mpl
import matplotlib.pyplot
import mpl_toolkits as mplt
import mpl_toolkits.mplot3d.axes3d
fig = mpl.pyplot.figure() # make Figure
ax = mpl.pyplot.gca(projection="3d")
circle1 = mpl.patches.Circle((5,1))
circle2 = mpl.patches.Circle((2,2))
# test 1 (throws ValueError):
#pc1 = matplotlib.collections.PatchCollection([circle1, circle2])
#ax.add_collection3d(pc1, zs=[1,2])
# test 2:
pc2 = mplt.mplot3d.art3d.Patch3DCollection([circle1, circle2], match_original=True)
ax.add_collection3d(pc2)test 1 results into a ValueError:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 519, in _draw_idle
self.draw()
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 402, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/figure.py", line 1649, in draw
renderer, self, artists, self.suppressComposite)
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 287, in draw
reverse=True)):
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 286, in <lambda>
key=lambda col: col.do_3d_projection(renderer),
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 400, in do_3d_projection
fcs = (zalpha(self._facecolor3d, vzs) if self._depthshade else
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 776, in zalpha
colors = get_colors(colors, len(zs))
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 767, in get_colors
(num, 4))
File "/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 176, in broadcast_to
return _broadcast_to(array, shape, subok=subok, readonly=True)
File "/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 128, in _broadcast_to
op_flags=[op_flag], itershape=shape, order='C')
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,4) and requested shape (1,4)
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 519, in _draw_idle
self.draw()
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 402, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/figure.py", line 1649, in draw
renderer, self, artists, self.suppressComposite)
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 287, in draw
reverse=True)):
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 286, in <lambda>
key=lambda col: col.do_3d_projection(renderer),
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 400, in do_3d_projection
fcs = (zalpha(self._facecolor3d, vzs) if self._depthshade else
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 776, in zalpha
colors = get_colors(colors, len(zs))
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 767, in get_colors
(num, 4))
File "/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 176, in broadcast_to
return _broadcast_to(array, shape, subok=subok, readonly=True)
File "/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 128, in _broadcast_to
op_flags=[op_flag], itershape=shape, order='C')
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,4) and requested shape (1,4)
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 519, in _draw_idle
self.draw()
File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 402, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/figure.py", line 1649, in draw
renderer, self, artists, self.suppressComposite)
File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 287, in draw
reverse=True)):
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 286, in <lambda>
key=lambda col: col.do_3d_projection(renderer),
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 400, in do_3d_projection
fcs = (zalpha(self._facecolor3d, vzs) if self._depthshade else
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 776, in zalpha
colors = get_colors(colors, len(zs))
File "/usr/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 767, in get_colors
(num, 4))
File "/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 176, in broadcast_to
return _broadcast_to(array, shape, subok=subok, readonly=True)
File "/usr/lib/python3.6/site-packages/numpy/lib/stride_tricks.py", line 128, in _broadcast_to
op_flags=[op_flag], itershape=shape, order='C')
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,4) and requested shape (1,4)test 2 results into a weird plot drenched into a blueish color, there is a visible object also (perhaps change the viewing angle) but it's not a circle.

Matplotlib 3.1.0
- Operating system: Void Linux
- Matplotlib version: 3.1.0
- Matplotlib backend Qt5Agg:
- Python version: 3.6.8
Metadata
Metadata
Assignees
Labels
status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: mplot3d
Activity
fidelram commentedon May 26, 2019
I am also getting the same error when saving a 3D image.
ivirshup commentedon Nov 12, 2020
@QuLogic, was this fixed by #18929? The plots at scanpy seem to be working with matplotlib 3.3.3.
qrzhang commentedon Nov 17, 2020
@ivirshup Yes, I think you're right. It works after I upgrade the matplotlib to version 3.3.3
pip install matplotlib --upgradeoscargus commentedon Jul 20, 2022
Parts of this seems to be related to scaling of the patches. Consider the following code:
Either version works, and gives the following plot:

github-actions commentedon Sep 8, 2025
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!