Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Seaborn标题错误-AttributeError:&x27;FaceGrid';对象没有属性';设置标题_Python_Seaborn - Fatal编程技术网

Python Seaborn标题错误-AttributeError:&x27;FaceGrid';对象没有属性';设置标题

Python Seaborn标题错误-AttributeError:&x27;FaceGrid';对象没有属性';设置标题,python,seaborn,Python,Seaborn,首先,我使用以下代码创建了一个线形图: plot = sns.lineplot(data=tips, x="sex", y="tip", ci=50, hue="day", palette="Accent") plot.set_title("Value of Tips Given

首先,我使用以下代码创建了一个线形图:

plot = sns.lineplot(data=tips,
             x="sex",
             y="tip",
             ci=50,
             hue="day",
             palette="Accent")
plot.set_title("Value of Tips Given to Waiters, by Days of the Week and Sex", fontsize=24, pad=30, fontdict={"weight": "bold"})
plot.legend("")
我意识到我需要的实际上是一个catplot图表,因此我将代码修改为以下内容:

plot = sns.catplot (data=tips,
             x="day",
             y="tip",
             kind='bar',
             ci=50,
             hue="sex",
             palette="Accent")
plot.set_title("Value of Tips Given to Waiters, by Days of the Week and Sex", fontsize=24, pad=30, fontdict={"weight": "bold"})
plot.legend("")
但是,我收到以下标题为的错误消息:“AttributeError:“FaceGrid”对象没有属性“set_title”


为什么我的标题不适用于catplot图表?

调用catplot时,它会返回一个FacetGrid对象,因此要更改标题并删除图例,必须在函数内使用
legend=
选项,并使用
plot.fig.suptitle()


这是否回答了您的问题?非常感谢,您是如何访问我正在使用的数据集的;)?!这是seaborn软件包的一部分<代码>提示=sns.load\u数据集(“提示”)
import seaborn as sns
tips = sns.load_dataset("tips")
plot = sns.catplot (data=tips,
             x="day",
             y="tip",
             kind='bar',
             ci=50,
             hue="sex",
             palette="Accent", legend=False)

plot.fig.suptitle("Value of Tips Given to Waiters, by Days of the Week and Sex",
                  fontsize=24, fontdict={"weight": "bold"})