You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation states that bbox should be an instance of matplotlib.transforms.Bbox.
When I try to use it like this I obtain the following error traceback below using matplotlib v3.6.2, whereas it works if I define it as e.g. bbox=[1, 1, 1, 1] which I guess (but just because I tried empirically) is equivalent to the method from_bounds() of Bbox.
TypeErrorTraceback (mostrecentcalllast)
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/IPython/core/formatters.py:972, inMimeBundleFormatter.__call__(self, obj, include, exclude)
969method=get_real_method(obj, self.print_method)
971ifmethodisnotNone:
-->972returnmethod(include=include, exclude=exclude)
973returnNone974else:
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/ipympl/backend_nbagg.py:336, inCanvas._repr_mimebundle_(self, **kwargs)
333plaintext=plaintext[:110] +'…'335buf=io.BytesIO()
-->336self.figure.savefig(buf, format='png', dpi='figure')
338base64_image=b64encode(buf.getvalue()).decode('utf-8')
339self._data_url= f'[data:image/png;base64,{](data:image/png;base64,{base64_image)[base64_image](data:image/png;base64,{base64_image)}'
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/figure.py:3274, inFigure.savefig(self, fname, transparent, **kwargs)
3270foraxinself.axes:
3271stack.enter_context(
3272ax.patch._cm_set(facecolor='none', edgecolor='none'))
->3274self.canvas.print_figure(fname, **kwargs)
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/backend_bases.py:2338, inFigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2334try:
2335# _get_renderer may change the figure dpi (as vector formats2336# force the figure dpi to 72), so we need to set it again here.2337withcbook._setattr_cm(self.figure, dpi=dpi):
->2338result=print_method(
2339filename,
2340facecolor=facecolor,
2341edgecolor=edgecolor,
2342orientation=orientation,
2343bbox_inches_restore=_bbox_inches_restore,
2344**kwargs)
2345finally:
2346ifbbox_inchesandrestore_bbox:
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/backend_bases.py:2204, inFigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2200optional_kws= { # Passed by print_figure for other renderers.2201"dpi", "facecolor", "edgecolor", "orientation",
2202"bbox_inches_restore"}
2203skip=optional_kws- {*inspect.signature(meth).parameters}
->2204print_method=functools.wraps(meth)(lambda*args, **kwargs: meth(
2205*args, **{k: vfork, vinkwargs.items() ifknotinskip}))
2206else: # Let third-parties do as they see fit.2207print_method=methFile~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/_api/deprecation.py:410, indelete_parameter.<locals>.wrapper(*inner_args, **inner_kwargs)
400deprecation_addendum= (
401f"If any parameter follows {name!r}, they should be passed as "402f"keyword, not positionally.")
403warn_deprecated(
404since,
405name=repr(name),
(...)
408elsedeprecation_addendum,
409**kwargs)
-->410returnfunc(*inner_args, **inner_kwargs)
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:517, inFigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs, *args)
468 @_api.delete_parameter("3.5", "args")
469defprint_png(self, filename_or_obj, *args,
470metadata=None, pil_kwargs=None):
471""" 472 Write the figure to a PNG file. 473 (...) 515 *metadata*, including the default 'Software' key. 516 """-->517self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:463, inFigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
458def_print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
459""" 460 Draw the canvas, then save it using `.image.imsave` (to which 461 *pil_kwargs* and *metadata* are forwarded). 462 """-->463FigureCanvasAgg.draw(self)
464mpl.image.imsave(
465filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
466dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:405, inFigureCanvasAgg.draw(self)
401# Acquire a lock on the shared font cache.402withRendererAgg.lock, \
403 (self.toolbar._wait_cursor_for_draw_cm() ifself.toolbar404elsenullcontext()):
-->405self.figure.draw(self.renderer)
406# A GUI class may be need to update a window using this draw, so407# don't forget to call the superclass.408super().draw()
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/artist.py:74, in_finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
72 @wraps(draw)
73defdraw_wrapper(artist, renderer, *args, **kwargs):
--->74result=draw(artist, renderer, *args, **kwargs)
75ifrenderer._rasterizing:
76renderer.stop_rasterizing()
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/artist.py:51, inallow_rasterization.<locals>.draw_wrapper(artist, renderer)
48ifartist.get_agg_filter() isnotNone:
49renderer.start_filter()
--->51returndraw(artist, renderer)
52finally:
53ifartist.get_agg_filter() isnotNone:
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/figure.py:3071, inFigure.draw(self, renderer)
3068# ValueError can occur when resizing a window.3070self.patch.draw(renderer)
->3071mimage._draw_list_compositing_images(
3072renderer, self, artists, self.suppressComposite)
3074forsfiginself.subfigs:
3075sfig.draw(renderer)
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/image.py:131, in_draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129ifnot_compositeornothas_images:
130forainartists:
-->131a.draw(renderer)
132else:
133# Composite any adjacent images together134image_group= []
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/artist.py:51, inallow_rasterization.<locals>.draw_wrapper(artist, renderer)
48ifartist.get_agg_filter() isnotNone:
49renderer.start_filter()
--->51returndraw(artist, renderer)
52finally:
53ifartist.get_agg_filter() isnotNone:
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/axes/_base.py:3107, in_AxesBase.draw(self, renderer)
3104a.draw(renderer)
3105renderer.stop_rasterizing()
->3107mimage._draw_list_compositing_images(
3108renderer, self, artists, self.figure.suppressComposite)
3110renderer.close_group('axes')
3111self.stale=FalseFile~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/image.py:131, in_draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129ifnot_compositeornothas_images:
130forainartists:
-->131a.draw(renderer)
132else:
133# Composite any adjacent images together134image_group= []
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/artist.py:51, inallow_rasterization.<locals>.draw_wrapper(artist, renderer)
48ifartist.get_agg_filter() isnotNone:
49renderer.start_filter()
--->51returndraw(artist, renderer)
52finally:
53ifartist.get_agg_filter() isnotNone:
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/table.py:409, inTable.draw(self, renderer)
407return408renderer.open_group('table', gid=self.get_gid())
-->409self._update_positions(renderer)
411forkeyinsorted(self._cells):
412self._cells[key].draw(renderer)
File~/Applications/mambaforge/envs/swgo-plot/lib/python3.9/site-packages/matplotlib/table.py:598, inTable._update_positions(self, renderer)
594l, b, w, h=bbox.bounds596ifself._bboxisnotNone:
597# Position according to bbox-->598rl, rb, rw, rh=self._bbox599self.scale(rw/w, rh/h)
600ox=rl-lTypeError: cannotunpacknon-iterableBboxobjectCanvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous view', 'arrow-left', 'back'), ('Forward', 'Forward to next view', 'arrow-right', 'forward'), ('Pan', 'Left button pans, Right button zooms\nx/y fixes axis, CTRL fixes aspect', 'arrows', 'pan'), ('Zoom', 'Zoom to rectangle\nx/y fixes axis', 'square-o', 'zoom'), ('Download', 'Download plot', 'floppy-o', 'save_figure')]))
Suggested improvement
Either let the parameter be a proper BBox (my suggestion) or specify that the usage is that of from_bounds()
The text was updated successfully, but these errors were encountered:
Thanks for reporting this! The table module is quite scarcely maintained, but this should be possible to fix. I guess supporting both the doc and the existing behavior is the way to go.
Documentation Link
https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.table.html#matplotlib.axes.Axes.table
Problem
The documentation states that
bbox
should be an instance ofmatplotlib.transforms.Bbox
.When I try to use it like this I obtain the following error traceback below using matplotlib v3.6.2, whereas it works if I define it as e.g.
bbox=[1, 1, 1, 1]
which I guess (but just because I tried empirically) is equivalent to the methodfrom_bounds()
of Bbox.Suggested improvement
Either let the parameter be a proper BBox (my suggestion) or specify that the usage is that of
from_bounds()
The text was updated successfully, but these errors were encountered: