Seaborn lmplot 色调绘图错误

数据挖掘 海运
2022-02-20 01:08:47

我正在尝试通过包含在 DataFrame 列中的分类变量为 lmplot 上的点着色,但出现以下错误:


ValueError                                Traceback (most recent call last)
<ipython-input-58-e0ac8c5bf9eb> in <module>
----> 1 sns.lmplot(x='TDS', y='Li', data=df_sub, hue='Group Location', legend=True)
      2 plt.show()

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\regression.py in lmplot(x, y, data, hue, col, row, palette, col_wrap, height, aspect, markers, sharex, sharey, hue_order, col_order, row_order, legend, legend_out, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, x_jitter, y_jitter, scatter_kws, line_kws, size)
    587         scatter_kws=scatter_kws, line_kws=line_kws,
    588         )
--> 589     facets.map_dataframe(regplot, x, y, **regplot_kws)
    590 
    591     # Add a legend

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\axisgrid.py in map_dataframe(self, func, *args, **kwargs)
    818 
    819             # Draw the plot
--> 820             self._facet_plot(func, ax, args, kwargs)
    821 
    822         # Finalize the annotations and layout

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs)
    836 
    837         # Draw the plot
--> 838         func(*plot_args, **plot_kwargs)
    839 
    840         # Sort out the supporting information

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\regression.py in regplot(x, y, data, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, dropna, x_jitter, y_jitter, label, color, marker, scatter_kws, line_kws, ax)
    787     scatter_kws["marker"] = marker
    788     line_kws = {} if line_kws is None else copy.copy(line_kws)
--> 789     plotter.plot(ax, scatter_kws, line_kws)
    790     return ax
    791 

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\regression.py in plot(self, ax, scatter_kws, line_kws)
    342             self.scatterplot(ax, scatter_kws)
    343         if self.fit_reg:
--> 344             self.lineplot(ax, line_kws)
    345 
    346         # Label the axes

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\regression.py in lineplot(self, ax, kws)
    387 
    388         # Fit the regression model
--> 389         grid, yhat, err_bands = self.fit_regression(ax)
    390 
    391         # Get set default aesthetics

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\regression.py in fit_regression(self, ax, x_range, grid)
    206             yhat, yhat_boots = self.fit_logx(grid)
    207         else:
--> 208             yhat, yhat_boots = self.fit_fast(grid)
    209 
    210         # Compute the confidence interval at each grid point

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\regression.py in fit_fast(self, grid)
    228 
    229         beta_boots = algo.bootstrap(X, y, func=reg_func,
--> 230                                     n_boot=self.n_boot, units=self.units).T
    231         yhat_boots = grid.dot(beta_boots).T
    232         return yhat, yhat_boots

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\algorithms.py in bootstrap(*args, **kwargs)
     84     boot_dist = []
     85     for i in range(int(n_boot)):
---> 86         resampler = rs.randint(0, n, n)
     87         sample = [a.take(resampler, axis=0) for a in args]
     88         boot_dist.append(f(*sample, **func_kwargs))

mtrand.pyx in mtrand.RandomState.randint()

ValueError: low >= high

分类变量是一个字符串。

0个回答
没有发现任何回复~