gpt4 book ai didi

python - 向子图添加背景颜色时的 MatplotlibDeprecationWarning

转载 作者:行者123 更新时间:2023-12-04 10:07:49 25 4
gpt4 key购买 nike

我正在尝试从数据集创建一个箱线图,然后更改每个子图的背景颜色:

url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/iris.csv"
column_names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
data_set = read_csv(url, names=column_names)


data_set.plot(kind="box", subplots=True, color="yellow", layout=(2, 2), sharex=False, sharey=False)

pyplot.subplot(221).set_facecolor("red")
pyplot.subplot(222).set_facecolor("purple")
pyplot.subplot(223).set_facecolor("green")
pyplot.subplot(224).set_facecolor("blue")

pyplot.show()

我确实得到了彩色子图,但是,我不断收到警告消息:
MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.

有谁知道如何解决这个问题?

最佳答案

这似乎是 Matplotlib 中的一个持续问题,截至今天尚未解决。从这里阅读线程 here ,似乎没有迫在眉睫的弃用风险。

但是,如果您希望此消息消失,您可以尝试该用户尝试的操作 here. .这里的用户更换了fig.subplot()fig.add_subplot()

关于python - 向子图添加背景颜色时的 MatplotlibDeprecationWarning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61483567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com