Pandas 用Seaborn打磨散点图传奇

Pandas 用Seaborn打磨散点图传奇,pandas,matplotlib,data-visualization,seaborn,scatter-plot,Pandas,Matplotlib,Data Visualization,Seaborn,Scatter Plot,下面使用seaborn为代码片段生成的散点图如下所示 ax = sns.scatterplot(x="Param_1", y="Param_2", hue="Process", style='Item', data=df, s=30, legend='full') 我想去掉圆圈中的颜色图例(用于流程),因

下面使用seaborn为代码片段生成的散点图如下所示

ax = sns.scatterplot(x="Param_1", 
                     y="Param_2", 
                     hue="Process", style='Item', data=df,
                     s=30, legend='full')

我想去掉圆圈中的颜色图例(用于流程),因为圆圈也表示“一”项的数据。在不与项目所用形状产生差异的情况下,呈现工艺用颜色图例的最佳方式是什么。

您可以创建所谓的图例,并将其用作图例符号

import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

fig,(ax1,ax2) = plt.subplots(ncols=2)
tips = sns.load_dataset("tips")

hue = "day"
style = "time"

sns.scatterplot(x="total_bill", y="tip", hue=hue, style=style, data=tips, ax=ax1)
ax1.set_title("Default Legend")
sns.scatterplot(x="total_bill", y="tip", hue=hue, style=style, data=tips, ax=ax2)
ax2.set_title("Custom Legend")

handles, labels = ax2.get_legend_handles_labels()
for i,label in enumerate(labels):
    if label == hue:
        continue
    if label == style:
        break
    handles[i] = mpatches.Patch(color=handles[i].get_fc()[0])
ax2.legend(handles, labels)

谢谢。我收到以下错误,AttributeError:“PathCollection”对象在尝试复制代码时没有属性“get_fc”。这里怎么了?嗯,你们有什么matplotlib版本?我使用
3.2.1
,它有