ValueError:颜色Kwarg每个数据集必须具有一种颜色。提供了4462个数据集和1种颜色

发布于 2025-02-13 08:09:36 字数 168 浏览 0 评论 0原文

我有一个我不理解的错误,这是很新的,所以请提前感谢! 我正在使用jupyter笔记本(anaconda3)此处的链接显示我的代码和错误消息

I have an error that I do not comprehend, am quite new to this so thank you all in advance!
I am using Jupyter Notebook (Anaconda3)The link here shows my code and error message

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

垂暮老矣 2025-02-20 08:09:36

问题是您的维度 all_unbalenced_data array/list。

如果您使用的是n维数据(n个不同的数据集,数据列表等)作为plt.hist.hist的输入,则color kwarg必须是相同的维度

您输入一种颜色,因此,要使脚本工作,您的数据必须形成为1维数组。

经验法则

假设您的数据包含在一个数组中:

all_unbalanced_data = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])

比您可以提取数组的形状( dimensionality ):

all_unbalanced_data.shape
>>> (2, 4)

颜色的数量plt.hist.hist将预计将为2:

color = ['color_code_1', 'color_code_2']

因此,在您的情况下,plt.hist期望有4462种不同的颜色。

The problem is the dimensionality of your all_unbalanced_data array/list.

If you are using an N-dimensional data (N different datasets, lists of data, etc) as input to plt.hist, then the color kwarg must be of the same dimensionality.

You input one single color, so for the script to work your data must be shaped as a 1-dimensional array.

A rule of thumb

Suppose your data are contained in a numpy array:

all_unbalanced_data = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])

Than you can extract the shape (dimensionality) of the array:

all_unbalanced_data.shape
>>> (2, 4)

The the number of colors plt.hist will expect will be 2:

color = ['color_code_1', 'color_code_2']

So in your case plt.hist is expecting 4462 different colors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文