【问题标题】:python: seaborn lineplot customize marker size based on values of a columnpython:seaborn lineplot根据列的值自定义标记大小
【发布时间】:2020-07-29 21:09:38
【问题描述】:

我有如下数据:

 #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)

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

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

  

【问题讨论】:

  • relplot(... sizes=(50,300) 增加大小。

标签: python seaborn visualization


【解决方案1】:

您似乎想将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)

【讨论】:

    猜你喜欢
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2020-09-24
    相关资源
    最近更新 更多