[Python] AttributeError: 'Figure' object has no attribute 'set_layout_engine'

Discussão em 'Python' iniciado por Stack, Janeiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am running a ggplot code in jupyter notebook. I've installed plotnine, but when I try to run, it give me the error AttributeError: 'Figure' object has no attribute 'set_layout_engine'

    The code is so symple:

    ( ggplot(df_nousd)
    + aes(x="raised_currency_code")
    + geom_bar(color="blue", alpha = 0.2)
    + labs(title='Tipo de moneda, capital por startup',
    x ='Tipo de moneda',
    y = 'Cuantía')
    )


    Appear:


    AttributeError Traceback (most recent call last)
    \~\\anaconda3\\lib\\site-packages\\IPython\\core\\formatters.py in __call__(self, obj)
    700 type_pprinters=self.type_printers,
    701 deferred_pprinters=self.deferred_printers)
    \--\> 702 printer.pretty(obj)
    703 printer.flush()
    704 return stream.getvalue()

    \~\\anaconda3\\lib\\site-packages\\IPython\\lib\\pretty.py in pretty(self, obj)
    392 if cls is not object \
    393 and callable(cls.__dict__.get('__repr__')):
    \--\> 394 return \_repr_pprint(obj, self, cycle)
    395
    396 return \_default_pprint(obj, self, cycle)

    \~\\anaconda3\\lib\\site-packages\\IPython\\lib\\pretty.py in _repr_pprint(obj, p, cycle)
    698 """A pprint that just redirects to the normal repr function."""
    699 # Find newlines and replace them with p.break_()
    \--\> 700 output = repr(obj)
    701 lines = output.splitlines()
    702 with p.group():

    \~\\anaconda3\\lib\\site-packages\\plotnine\\ggplot.py in __repr__(self)
    112 Print/show the plot
    113 """
    \--\> 114 figure = self.draw(show=True)
    115
    116 dpi = figure.get_dpi()

    \~\\anaconda3\\lib\\site-packages\\plotnine\\ggplot.py in draw(self, show)
    239 # Artist object theming
    240 self.theme.apply()
    \--\> 241 figure.set_layout_engine(PlotnineLayoutEngine(self))
    242
    243 return self.figure

    AttributeError: 'Figure' object has no attribute 'set_layout_engine'


    Anyone can help with this error?

    I was searching here some solution, but nowhere appear a similar error with that report.

    Continue reading...

Compartilhe esta Página