1
resposta

Erro na criação do gráfico catplot seaborn

generos_sum_df
sns.catplot(x = generos_sum_df.index, y = "Quantidade", data = generos_sum_df, 
            aspect=2,
            kind= "bar",
            palette="ch:2.5,.2,dark=.3")

O meu código é esse e inclusive ele plota o gráfico do jeito que eu quero porém ele dá os seguintes erros:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-74-40232dd4f167> in <module>
      4             aspect=2,
      5             kind= "bar",
----> 6             palette="ch:2.5,.2,dark=.3")

~\Anaconda3.7\lib\site-packages\seaborn\categorical.py in catplot(x, y, hue, data, row, col, col_wrap, estimator, ci, n_boot, units, order, hue_order, row_order, col_order, kind, height, aspect, orient, color, palette, legend, legend_out, sharex, sharey, margin_titles, facet_kws, **kwargs)
   3753 
   3754     # Draw the plot onto the facets
-> 3755     g.map_dataframe(plot_func, x, y, hue, **plot_kws)
   3756 
   3757     # Special case axis labels for a count type plot

~\Anaconda3.7\lib\site-packages\seaborn\axisgrid.py in map_dataframe(self, func, *args, **kwargs)
    821 
    822         # Finalize the annotations and layout
--> 823         self._finalize_grid(args[:2])
    824 
    825         return self

~\Anaconda3.7\lib\site-packages\seaborn\axisgrid.py in _finalize_grid(self, axlabels)
    844     def _finalize_grid(self, axlabels):
    845         """Finalize the annotations and layout."""
--> 846         self.set_axis_labels(*axlabels)
    847         self.set_titles()
    848         self.fig.tight_layout()

~\Anaconda3.7\lib\site-packages\seaborn\axisgrid.py in set_axis_labels(self, x_var, y_var)
    870         if x_var is not None:
    871             self._x_var = x_var
--> 872             self.set_xlabels(x_var)
    873         if y_var is not None:
    874             self._y_var = y_var

~\Anaconda3.7\lib\site-packages\seaborn\axisgrid.py in set_xlabels(self, label, **kwargs)
    881             label = self._x_var
    882         for ax in self._bottom_axes:
--> 883             ax.set_xlabel(label, **kwargs)
    884         return self
    885 

~\Anaconda3.7\lib\site-packages\matplotlib\axes\_axes.py in set_xlabel(self, xlabel, fontdict, labelpad, **kwargs)
    263         if labelpad is not None:
    264             self.xaxis.labelpad = labelpad
--> 265         return self.xaxis.set_label_text(xlabel, fontdict, **kwargs)
    266 
    267     def get_ylabel(self):

~\Anaconda3.7\lib\site-packages\matplotlib\axis.py in set_label_text(self, label, fontdict, **kwargs)
   1562         """
   1563         self.isDefault_label = False
-> 1564         self.label.set_text(label)
   1565         if fontdict is not None:
   1566             self.label.update(fontdict)

~\Anaconda3.7\lib\site-packages\matplotlib\text.py in set_text(self, s)
   1189         if s is None:
   1190             s = ''
-> 1191         if s != self._text:
   1192             self._text = '%s' % (s,)
   1193             self.stale = True

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Alguém sabe o que posso estar fazendo de errado?

1 resposta

Olá Marcelo,

Para ter certeza da causa só vendo o código completo, pode ser algo relacionado a versão de alguma das bibliotecas utilizadas.