how to display corresponding legend when using scale_shape_identity()?

223 views Asked by At

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.

0

There are 0 answers