Add borders to the shapes in the PCA plot by using autoplot
Hi,
I was able to plot the PCA between two different variables using function autoplot() function from ggfortify library. I have a question about how to add the black borders around the circles and triangles as shown in the plot below. Please let me know if there any specific function for adding?
Thank you,
Toufiq
## PCA on two variables##
pca_v1 <- prcomp(Node, scale. = TRUE)
autoplot(pca_v1,
data = Neg_Dct, colour = 'Category', shape = 'Response' , size = 3.5) +
theme_classic()

• 4,204 views
•
link
1 answer
We can achieve the same using basic ggplot, see example:
library(ggplot2)
#example data
df1 <- data.frame(
x = 1:10,
y = 1:10,
grp = rep(LETTERS[1:2], 5)
)
ggplot(df1, aes(x, y, col = "black", fill = grp, shape = grp)) +
geom_point() +
scale_color_identity() +
scale_fill_manual(values = c("red", "green")) +
scale_shape_manual(values = c(21, 24)) +
theme_classic()
We need to use shapes that can have colour and fill separately: http://www.sthda.com/english/wiki/r-plot-pch-symbols-the-different-point-shapes-available-in-r
• 0 views
•
link
Log in to answer this question.
Try this code and let us have your comments here: