【问题标题】:Add data to a seaborn jointplot将数据添加到 seaborn 联合图
【发布时间】:2015-11-05 23:20:23
【问题描述】:

我使用以下 seaborn 方法(其中回报和波动率是浮点数列表)得到了一个不错的 KDE 联合图:

data=pd.DataFrame({"return":returns,"volatility":volatilities,})
a=sns.jointplot(x="volatility", y="return", data=data, size=10)

如何在此联合图上叠加特定点?例如,如果我想在位置 (0.2,0.2) 的 KDE 聊天上叠加一个红点

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:

    您可以像这样在jointplot 的关节轴上绘图:

    a=sns.jointplot(x="volatility", y="return", data=data, size=10)
    a.ax_joint.plot([0.2],[0.2],'ro')
    

    顺便说一句,您还可以使用

    访问 xy 边距子图
    a.ax_marg_x
    a.ax_marg_y
    

    【讨论】:

    • 谢谢。你知道如何给那个点添加标签吗? a.ax_joint.plot([0.2],[0.2],'ro', label='test') 似乎没有显示任何内容。
    • a.ax_joint.text(0.2,0.2,'test') ?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 2020-09-12
    • 2014-12-09
    • 2022-01-17
    • 2020-12-31
    相关资源
    最近更新 更多