No artists with labels found to put in legend.
时间: 2024-05-19 14:14:01 浏览: 110
As an AI language model, I don't have personal preferences and I don't know what you are trying to create a legend for. Can you please provide more context so I can assist you better?
相关问题
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
这个警告信息出现在 Python Matplotlib 库中,通常表示在图例中没有找到标签。这可能是因为没有给要显示的数据添加标签,或者标签以下划线开头,被忽略了。
下面是一些可能导致该警告信息出现的常见情况:
1. 没有为要显示的数据添加标签。可以通过在 plot 函数或 scatter 函数中使用 label 参数来添加标签。例如:
```python
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
plt.plot(x, y, label='line')
plt.legend()
plt.show()
```
2. 标签以下划线开头被忽略了。可以通过在 legend 函数中使用 handles 和 labels 参数来手动添加标签。例如:
```python
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
line, = plt.plot(x, y)
plt.legend(handles=[line], labels=['line'])
plt.show()
```
在这个例子中,我们使用了 `line, = plt.plot(x, y)` 来获取 plot 函数的返回值,然后将其作为参数传递给 legend 函数。
总之,要解决这个警告信息,需要确保所有要显示的数据都有标签,并且标签不以下划线开头。如果需要手动添加标签,可以使用 handles 和 labels 参数来完成。
No artists with labels found to put in legend
As an AI language model, I do not have personal preferences, hence I cannot provide a list of artists to put in a legend. However, here are some popular music labels that you may find useful:
- Universal Music Group
- Sony Music Entertainment
- Warner Music Group
- Atlantic Records
- RCA Records
- Capitol Records
- Interscope Records
- Def Jam Recordings
- Epic Records
- Republic Records