R 使用scale_shape_identity()时如何显示相应的图例?

R 使用scale_shape_identity()时如何显示相应的图例?,r,ggplot2,autoplot,R,Ggplot2,Autoplot,您好,我有一个显示PCA REUSELT的图,问题是我想显示点在图中的行为如何取决于两个变量,比如采样日期和采样深度: 我使用autoplot进行此操作: autoplot(PCA_results, data = data1, colour = 'sample_date' , shape = 'depth_m', main = "PCA for samples") + scale_shape_identity() 我不得不使用scale\u shape\u ide

您好,我有一个显示PCA REUSELT的图,问题是我想显示点在图中的行为如何取决于两个变量,比如采样日期和采样深度:

我使用autoplot进行此操作:

autoplot(PCA_results, data = data1, colour = 'sample_date' ,
     shape = 'depth_m', main = "PCA for samples") + scale_shape_identity()
我不得不使用
scale\u shape\u identity()
,因为“depth\u m”变量有两个连续值(5米和20米),如果没有
scale\u shape\u identity()

结果图如下所示:

所以,除了在图例中显示sample_date变量外,我还想显示depth变量,我该怎么做呢?
scale\u shape\u identity()
的“帮助”菜单说明“这些比例不会生成图例,除非您还提供所需的分隔符、标签和指南类型。”但我不确定如何提供标签,中断和指南类型。

如果您包含一个简单的示例输入和所需的输出,可以用来测试和验证可能的解决方案,则更容易帮助您。默认情况下,
scale\u xxx\u identity
“不会生成图例”(请参见
?scale\u shape\u identity
)。尝试使用
scale\u shape\u identity(guide=“legend”)