Plotting two distributions in seaborn.jointplot

前端 未结 3 1726
忘了有多久
忘了有多久 2020-12-09 19:36

I have two pandas dataframes I would like to plot in the same seaborn jointplot. It looks something like this (commands are don in an IPython shell; ipyth

3条回答
  •  情书的邮戳
    2020-12-09 20:18

    It might be easier after drawing the jointplot, change to the axis on which you want to draw something and use then normal pyplot or axis based seaborn plots:

    g=sns.jointplot(...)
    plt.sca("axis_name")
    plt.plot/plt.scatter/.../sns.kde(ax="axis_name")
    

    The axis name is either ax_joint for the 2d-Plot or ax_marg_x or ax_marg_y for the 1d Plots on the side.

    Furthermore, if you want to use the jointplot structure but plot all plots by pyplot, use the cla function, e.g. for clearing the 2d-Plot:

    g.ax_joint.cla()
    

提交回复
热议问题