'Change the size and specify a colour to one data point in autoplot Prcomp
I have plotted PC using autoplot and coloured it based on the species(~30 species). Of these I need to highlight only one selected species with different colour and size.
autoplot(sample_pca, data = sample, colour = "species")
Solution 1:[1]
library(ggfortify)
#> Loading required package: ggplot2
library(tidyverse)
samples <-
iris |>
mutate(is_setosa = (Species == "setosa") |> ifelse("setosa", "other"))
iris |>
select(-Species) |>
prcomp() |>
autoplot(data = samples, colour = "is_setosa", size = "is_setosa")
#> Warning: Using size for a discrete variable is not advised.

Created on 2022-05-18 by the reprex package (v2.0.0)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | danlooo |
