0

我使用主数据框 r_df 并计算“p”和“效用”之间的线性回归,包括线参数和 R 平方。那是r_df:

    Utility    p  mean   sd  iteration
90   0.075858  1.0   0.5  0.3       10.0
91   0.075858  1.0   0.5  0.4       10.0
92   0.075858  1.0   0.5  0.5       10.0
93   0.500000  1.0   1.0  0.3       10.0
94   0.500000  1.0   1.0  0.4       10.0
95   0.500000  1.0   1.0  0.5       10.0
96   0.924142  1.0   1.5  0.3       10.0
97   0.924142  1.0   1.5  0.4       10.0
98   0.924142  1.0   1.5  0.5       10.0
99   0.124008  0.0   0.5  0.3      100.0
100  0.149518  0.0   0.5  0.4      100.0
101  0.168911  0.0   0.5  0.5      100.0
102  0.516585  0.0   1.0  0.3      100.0
103  0.511339  0.0   1.0  0.4      100.0
104  0.551679  0.0   1.0  0.5      100.0

那就是数据框df_iter,它存储了线性回归的参数:

            slope  intercept     R sqr  mean   sd  iteration
90   0.010329   0.494478  0.003605   1.0  0.3       10.0
91   0.001569   0.498630  0.000736   1.0  0.3      100.0
92  -0.000294   0.500254  0.000252   1.0  0.3     1000.0
93  -0.003057   0.499894  0.000206   1.0  0.4       10.0
94  -0.000732   0.501374  0.000117   1.0  0.4      100.0
95   0.000047   0.499954  0.000005   1.0  0.4     1000.0
96   0.007904   0.495582  0.001036   1.0  0.5       10.0
97   0.001049   0.499832  0.000193   1.0  0.5      100.0
98  -0.001417   0.500882  0.003341   1.0  0.5     1000.0
99   0.063473   0.869365  0.305991   1.5  0.3       10.0
100  0.063074   0.870057  0.799972   1.5  0.3      100.0
101  0.063367   0.869828  0.924101   1.5  0.3     1000.0
102  0.098548   0.838722  0.369288   1.5  0.4       10.0
103  0.102952   0.835050  0.831155   1.5  0.4      100.0
104  0.101127   0.836301  0.944319   1.5  0.4     1000.0

现在,我使用 seaborn catplot 显示来自 r_df 的数据,代码如下:

s2 = sns.catplot(x="iteration", y="slope",
                 data=df_iter,
                 sharey="row",
                 hue="sd",
                 col="mean",
                 palette="crest")
s2.map(plt.axhline, y=0, ls='--', c='red')

结果是这样的:
斜率图

现在,我真的想在现有的 catplot 上添加 R 平方值的点。我设法分别绘制它们,但我找不到将点添加到具有多个轴的 catplot 的方法(我从一开始就选择使用这种类型的原因是列和行的简单选项)。我只找到了与 catplot 相关的单轴答案。

ax2 = sns.catplot(x="iteration", y="R sqr",
                 data=df_iter,
                 sharey="row",
                 hue="sd",
                 col="mean",
                 palette="rocket")
ax2.map(plt.axhline, y=0, ls='--', c='red')

R平方值的图表:
R 平方值的图表

即使将 R 平方值作为单个点(而不是另一个图)添加到第一个图中也很好,但我找不到如何在 seaborn 图形级别对象中指定子图。

4

0 回答 0