【问题标题】:python Seaborn - annotations with pointplotpython Seaborn - 带有点图的注释
【发布时间】:2017-09-14 21:02:13
【问题描述】:

我在 seaborn 中使用点图。

import seaborn as sns
sns.set_style("darkgrid")
tips = sns.load_dataset("tips")
ax = sns.pointplot(x="time", y="total_bill", hue="smoker",data=tips)

我想注释所有的点。如果中间有点,如果有意义的话,我想标记中间的点以及线的末端。

非常感谢!

【问题讨论】:

    标签: python seaborn


    【解决方案1】:

    这个问题相当不具体,但这里是如何标记点图中的每个点,就像您对任何其他 matplotlib 散点图所做的那样:

    import matplotlib.pyplot as plt
    import seaborn as sns
    
    tips = sns.load_dataset("tips")
    ax = sns.pointplot(x="time", y="total_bill", hue="smoker", data=tips)
    
    for c in ax.collections:
        for of in c.get_offsets():
            ax.annotate("Label", of)
    
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-26
      • 2017-01-02
      • 2017-01-24
      • 2016-01-14
      • 2020-08-10
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多