簡體   English   中英

python:seaborn 線圖根據列的值自定義標記大小

[英]python: seaborn lineplot customize marker size based on values of a column

我有如下數據:

 #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

如果我執行以下代碼,我將擁有:

  sns.relplot(x = 'id', y = 'val', hue = 'indicator', size = 'count', data = df)

在此處輸入圖像描述

我想要一條連接點的線。 但是,如果我將 plot 更改為 plot 行,我將有任何圖表。

sns.lineplot(x = 'id', y = 'val', hue = 'indicator', size = 'count', data = df)

  

在此處輸入圖像描述

似乎您想將lineplotscatterplot結合起來

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

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM