根据列的值自定义线图标记大小

lll*_*lll 2 python line-plot seaborn

我有如下数据:

 #df
  df = pd.DataFrame({
               'id': {0: -3, 1: 2, 2: -3, 3: 1},
               'val': {0: 0.4, 1: 0.03, 2: 0.88, 3: 1.3},
               'indicator': {0: 'A', 1: 'A', 2: 'B', 3: 'B'},
               'count': {0: 40000, 1: 5779, 2: 3000, 3: 31090}
              })
df
Run Code Online (Sandbox Code Playgroud)

如果我执行以下代码,我将得到:

 sns.relplot(x = 'id', y = 'val', hue = 'indicator', size = 'count', data = df)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我想要一条线连接这些点。但如果我将绘图更改为线图,我将得到任何图表。

sns.lineplot(x = 'id', y = 'val', hue = 'indicator', size = 'count', data = df)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Diz*_*ahi 7

似乎你想将 alineplot与 a结合起来scatterplot

plt.figure()
sns.lineplot(x = 'id', y = 'val', hue = 'indicator', data = df)
sns.scatterplot(x = 'id', y = 'val', hue = 'indicator', size = 'count', data = df)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述