Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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散点图中删除两个传说中的一个_Python_Pandas_Matplotlib_Seaborn - Fatal编程技术网

Python 从Seaborn散点图中删除两个传说中的一个

Python 从Seaborn散点图中删除两个传说中的一个,python,pandas,matplotlib,seaborn,Python,Pandas,Matplotlib,Seaborn,使用“提示”数据集作为玩具模型,我生成以下绘图: import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset("tips") cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True) g = sns.scatterplot(x="total_bill", y="sex", hue="smoker", size = 'tip',size

使用“提示”数据集作为玩具模型,我生成以下绘图:

import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")

cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True)
g = sns.scatterplot(x="total_bill", y="sex", hue="smoker", size = 'tip',sizes=(320, 600), data=tips)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0., fontsize=13)
plt.show(g)
这张照片正是我需要的。但是,我想从图例中删除
size='tip'
,只保留吸烟者。基本上,删除标记为0.0到12.0的黑色圆圈。如何确保我的图例只有一个可供选择的变量


我能够通过索引图例中的标签找到修复方法

import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")

cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True)
g = sns.scatterplot(x="total_bill", y="sex", hue="smoker", size = 'tip',sizes=(320, 600), data=tips)
h,l = g.get_legend_handles_labels()
plt.legend(h[0:3],l[0:3],bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0., fontsize=13)
plt.show(g)

我能够通过索引图例中的标签找到修复方法

import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")

cmap = sns.cubehelix_palette(dark=.3, light=.8, as_cmap=True)
g = sns.scatterplot(x="total_bill", y="sex", hue="smoker", size = 'tip',sizes=(320, 600), data=tips)
h,l = g.get_legend_handles_labels()
plt.legend(h[0:3],l[0:3],bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0., fontsize=13)
plt.show(g)