鱼C论坛

 找回密码
 立即注册
查看: 727|回复: 1

seaborn画图出错

[复制链接]
发表于 2022-1-4 20:15:52 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
使用seaborn画图的时候出错了,但是不知道是那里的问题

fig = sns.catplot(data=data, x='SPE', y='Acceptance.RESP'
                 ,kind='point'
                  ,hue='evaluation'
                 #,col_wrap=3
                  ,estimator=np.mean
                  ,ci=None
                 )


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_51344/1292113035.py in <module>
      1 # 单个被试
----> 2 fig = sns.catplot(data=data, x='SPE', y='Acceptance.RESP'
      3                  ,kind='point'
      4                   ,hue='evaluation'
      5                  #,col_wrap=3

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\_decorators.py in inner_f(*args, **kwargs)
     44             )
     45         kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46         return f(**kwargs)
     47     return inner_f
     48

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\categorical.py in catplot(x, y, hue, data, row, col, col_wrap, estimator, ci, n_boot, units, seed, order, hue_order, row_order, col_order, kind, height, aspect, orient, color, palette, legend, legend_out, sharex, sharey, margin_titles, facet_kws, **kwargs)
   3845
   3846     # Draw the plot onto the facets
-> 3847     g.map_dataframe(plot_func, x=x, y=y, hue=hue, **plot_kws)
   3848
   3849     if p.orient == "h":

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\axisgrid.py in map_dataframe(self, func, *args, **kwargs)
    775
    776             # Draw the plot
--> 777             self._facet_plot(func, ax, args, kwargs)
    778
    779         # For axis labels, prefer to use positional args for backcompat

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs)
    804             plot_args = []
    805             plot_kwargs["ax"] = ax
--> 806         func(*plot_args, **plot_kwargs)
    807
    808         # Sort out the supporting information

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\_decorators.py in inner_f(*args, **kwargs)
     44             )
     45         kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 46         return f(**kwargs)
     47     return inner_f
     48

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\categorical.py in pointplot(x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, seed, markers, linestyles, dodge, join, scale, orient, color, palette, errwidth, capsize, ax, **kwargs)
   3381         ax = plt.gca()
   3382
-> 3383     plotter.plot(ax)
   3384     return ax
   3385

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\categorical.py in plot(self, ax)
   1786     def plot(self, ax):
   1787         """Make the plot."""
-> 1788         self.draw_points(ax)
   1789         self.annotate_axes(ax)
   1790         if self.orient == "h":

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\categorical.py in draw_points(self, ax)
   1779                     x = y = [np.nan] * n_points
   1780
-> 1781                 ax.scatter(x, y, label=hue_level,
   1782                            facecolor=color, edgecolor=color,
   1783                            linewidth=mew, marker=marker, s=markersize,

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, data, *args, **kwargs)
   1445     def inner(ax, *args, data=None, **kwargs):
   1446         if data is None:
-> 1447             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1448
   1449         bound = new_sig.bind(ax, *args, **kwargs)

C:\ProgramData\Anaconda3\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

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, **kwargs)
   4486         offsets = np.ma.column_stack([x, y])
   4487
-> 4488         collection = mcoll.PathCollection(
   4489                 (path,), scales,
   4490                 facecolors=colors,

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in __init__(self, paths, sizes, **kwargs)
    951         """
    952
--> 953         super().__init__(**kwargs)
    954         self.set_paths(paths)
    955         self.set_sizes(sizes)

C:\ProgramData\Anaconda3\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

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
    173         self._hatch_color = mcolors.to_rgba(mpl.rcParams['hatch.color'])
    174         self.set_facecolor(facecolors)
--> 175         self.set_edgecolor(edgecolors)
    176         self.set_linewidth(linewidths)
    177         self.set_linestyle(linestyles)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in set_edgecolor(self, c)
    828         """
    829         self._original_edgecolor = c
--> 830         self._set_edgecolor(c)
    831
    832     def set_alpha(self, alpha):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\collections.py in _set_edgecolor(self, c)
    812         except AttributeError:
    813             pass
--> 814         self._edgecolors = mcolors.to_rgba_array(c, self._alpha)
    815         if set_hatch_color and len(self._edgecolors):
    816             self._hatch_color = tuple(self._edgecolors[0])

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\colors.py in to_rgba_array(c, alpha)
    339         return np.zeros((0, 4), float)
    340     else:
--> 341         return np.array([to_rgba(cc, alpha) for cc in c])
    342
    343

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\colors.py in <listcomp>(.0)
    339         return np.zeros((0, 4), float)
    340     else:
--> 341         return np.array([to_rgba(cc, alpha) for cc in c])
    342
    343

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\colors.py in to_rgba(c, alpha)
    187         rgba = None
    188     if rgba is None:  # Suppress exception chaining of cache lookup failure.
--> 189         rgba = _to_rgba_no_colorcycle(c, alpha)
    190         try:
    191             _colors_full_map.cache[c, alpha] = rgba

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\colors.py in _to_rgba_no_colorcycle(c, alpha)
    261     # tuple color.
    262     if not np.iterable(c):
--> 263         raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
    264     if len(c) not in [3, 4]:
    265         raise ValueError("RGBA sequence should have length 3 or 4")

ValueError: Invalid RGBA argument: 0.12156862745098039
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2022-1-4 20:17:36 | 显示全部楼层
evaluation这一列数据是int(0)或者int(1)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-5 21:13

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表