Repository navigation
Closed
Labels
API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …status: has patchpatch suggested, PR still neededpatch suggested, PR still neededtopic: mplot3d
Milestone
Description
Bug report
Bug summary
Using path_effects keyword on a 2D scatterplot works, e.g. to draw outlines on markers. For a 3D scatterplot with only one element, the keyword has no effect, while for a 3D scatterplot with more than one element, it leads to an exception
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects
fig = plt.figure()
ax = fig.gca(projection='3d')
pe = [path_effects.Stroke(linewidth=4, foreground='white'), path_effects.Normal()]
x = np.linspace(-2, 2)
X, Y = np.meshgrid(x, x)
Z = (X+Y)**2
ax.plot_surface(X, Y, Z, zorder=-1, alpha=0.5)
ax.scatter([0, 1, 2], [0, 1, 2], [2, 1, 2], path_effects=pe, zorder=0)
plt.show()Actual outcome
---------------------------------------------------------------------------
SystemError Traceback (most recent call last)
~\AppData\Local\Programs\Python\Python38\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
339 pass
340 else:
--> 341 return printer(obj)
342 # Finally look for special method names
343 method = get_real_method(obj, self.print_method)
~\AppData\Local\Programs\Python\Python38\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig)
246
247 if 'png' in formats:
--> 248 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
249 if 'retina' in formats or 'png2x' in formats:
250 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
~\AppData\Local\Programs\Python\Python38\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
130 FigureCanvasBase(fig)
131
--> 132 fig.canvas.print_figure(bytes_io, **kw)
133 data = bytes_io.getvalue()
134 if fmt == 'svg':
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2208
2209 try:
-> 2210 result = print_method(
2211 filename,
2212 dpi=dpi,
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backend_bases.py in wrapper(*args, **kwargs)
1637 kwargs.pop(arg)
1638
-> 1639 return func(*args, **kwargs)
1640
1641 return wrapper
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, metadata, pil_kwargs, *args)
507 *metadata*, including the default 'Software' key.
508 """
--> 509 FigureCanvasAgg.draw(self)
510 mpl.image.imsave(
511 filename_or_obj, self.buffer_rgba(), format="png", origin="upper",
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\backend_agg.py in draw(self)
405 (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
406 else nullcontext()):
--> 407 self.figure.draw(self.renderer)
408 # A GUI class may be need to update a window using this draw, so
409 # don't forget to call the superclass.
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
1861
1862 self.patch.draw(renderer)
-> 1863 mimage._draw_list_compositing_images(
1864 renderer, self, artists, self.suppressComposite)
1865
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~\AppData\Local\Programs\Python\Python38\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py in draw(self, renderer)
462
463 # Then rest
--> 464 super().draw(renderer)
465
466 def get_axis_position(self):
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
409 else deprecation_addendum,
410 **kwargs)
--> 411 return func(*inner_args, **inner_kwargs)
412
413 return wrapper
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
2745 renderer.stop_rasterizing()
2746
-> 2747 mimage._draw_list_compositing_images(renderer, self, artists)
2748
2749 renderer.close_group('axes')
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
929 def draw(self, renderer):
930 self.set_sizes(self._sizes, self.figure.dpi)
--> 931 Collection.draw(self, renderer)
932
933
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
404 mpath.Path(offsets), transOffset, tuple(facecolors[0]))
405 else:
--> 406 renderer.draw_path_collection(
407 gc, transform.frozen(), paths,
408 self.get_transforms(), offsets, transOffset,
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\patheffects.py in draw_path_collection(self, gc, master_transform, paths, *args, **kwargs)
136 # Recursively call this method, only next time we will only have
137 # one path effect.
--> 138 renderer.draw_path_collection(gc, master_transform, paths,
139 *args, **kwargs)
140
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\patheffects.py in draw_path_collection(self, gc, master_transform, paths, *args, **kwargs)
128 # Call the base path effect function - this uses the unoptimised
129 # approach of calling "draw_path" multiple times.
--> 130 return RendererBase.draw_path_collection(self, gc,
131 master_transform, paths,
132 *args, **kwargs)
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backend_bases.py in draw_path_collection(self, gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)
240 transform = transform.frozen()
241 transform.translate(xo, yo)
--> 242 self.draw_path(gc0, path, transform, rgbFace)
243
244 def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\patheffects.py in draw_path(self, gc, tpath, affine, rgbFace)
98 def draw_path(self, gc, tpath, affine, rgbFace=None):
99 for path_effect in self._path_effects:
--> 100 path_effect.draw_path(self._renderer, gc, tpath, affine,
101 rgbFace)
102
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\patheffects.py in draw_path(self, renderer, gc, tpath, affine, rgbFace)
211 gc0.copy_properties(gc)
212 gc0 = self._update_gc(gc0, self._gc)
--> 213 renderer.draw_path(
214 gc0, tpath, affine + self._offset_transform(renderer), rgbFace)
215 gc0.restore()
~\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\backend_agg.py in draw_path(self, gc, path, transform, rgbFace)
157 else:
158 try:
--> 159 self._renderer.draw_path(gc, path, transform, rgbFace)
160 except OverflowError as err:
161 raise OverflowError("Exceeded cell block limit (set "
SystemError: new style getargs format but argument is not a tuple
3D scatterplot with path effects applied to markers.
Matplotlib version
- Operating system: Windows 10
- Matplotlib version: 3.3.4
- Matplotlib backend: (independent of backend)
- Python version: 3.8.2
- Jupyter version (if applicable): (also occurs outside)
- Other libraries: (numpy, but not relevant for the bug)
Metadata
Metadata
Assignees
Labels
API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …status: has patchpatch suggested, PR still neededpatch suggested, PR still neededtopic: mplot3d
Activity
[-]path_effects kwarg lead to exception on 3D scatterplot[/-][+]path_effects kwarg triggers exception on 3D scatterplot[/+]anntzer commentedon Feb 23, 2021
Thanks for the report. Looks like we need (e.g.)
which should also fix #8650.
Writing a test is left as an exercise to the reader.