[Python] AttributeError: 'matplotlib.backends._backend_agg.RendererAgg' object has no...

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I've been trying to run the following code which is meant to plot some histograms of some data.

    viz = cdf[['CYLINDERS','ENGINESIZE','FUELCONSUMPTION_COMB','CO2EMISSIONS']]
    viz.hist()
    plt.show()


    This is the error message that I get when I try to run it:

    ---------------------------------------------------------------------------
    AttributeError Traceback (most recent call last)
    File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\IPython\core\formatters.py:339, in BaseFormatter.__call__(self, obj)
    337 pass
    338 else:
    --> 339 return printer(obj)
    340 # Finally look for special method names
    341 method = get_real_method(obj, self.print_method)

    File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\IPython\core\pylabtools.py:151, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    148 from matplotlib.backend_bases import FigureCanvasBase
    149 FigureCanvasBase(fig)
    --> 151 fig.canvas.print_figure(bytes_io, **kw)
    152 data = bytes_io.getvalue()
    153 if fmt == 'svg':

    File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\matplotlib\backend_bases.py:2289, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
    2282 bbox_inches = rcParams['savefig.bbox']
    2284 if (self.figure.get_constrained_layout() or
    2285 bbox_inches == "tight"):
    2286 # we need to trigger a draw before printing to make sure
    2287 # CL works. "tight" also needs a draw to get the right
    2288 # locations:
    -> 2289 renderer = _get_renderer(
    2290 self.figure,
    ...
    --> 110 self.draw_gouraud_triangle = self._renderer.draw_gouraud_triangle
    111 self.draw_gouraud_triangles = self._renderer.draw_gouraud_triangles
    112 self.draw_image = self._renderer.draw_image

    AttributeError: 'matplotlib.backends._backend_agg.RendererAgg' object has no attribute 'draw_gouraud_triangle'


    Can someone please explain what I should do about this?

    Continue reading...

Compartilhe esta Página