0

Hello I Have a plot showing a PCA reuslt, the issue is that I want to show how the points behave in the plot accoriding to two variables, let's say sample date and depth of sampling:

I use autoplot for this porpuse:

autoplot(PCA_results, data = data1, colour = 'sample_date' ,
     shape = 'depth_m', main = "PCA for samples") + scale_shape_identity()

I had to use scale_shape_identity() due to the fact that the "depth_m" variable have two continuous values (5 meters and 20 meters) and was not acepted without scale_shape_identity()

the resulting plot is the following one:

enter image description here

So in addition to showing sample_date variable in the legend I want to display the depth one too, how can I do this ? The description of the help menu of scale_shape_identity() appoints that "These scales will not produce a legend unless you also supply the breaks, labels, and type of guide you want." But I'm not sure how to provide the labels, breaks and type of guide.

Valentin
  • 399
  • 2
  • 10
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick May 11 '21 at 20:03
  • By default `scale_xxx_identity` "will not produce a legend" (see `? scale_shape_identity`). Try with `scale_shape_identity(guide = "legend")` – stefan May 11 '21 at 23:33

0 Answers0