Closed mfisher5 closed 4 years ago
Thank you for improving visualization of ordinations! I'd like to be able to change the point shape independent of the 'grp_in' variable, as you can do currently with the point size using the size
argument. However, I cannot seem to override the ggord
defaults using scale_shape_manual
+ a different grouping variable. Would it be possible to update the existing code with this new feature?
@mfisher5 this is not easy to do since the groups are linked to the shape and colour aesthetics inside the ggord plot functions. However, you can do this manually using this super-hacky code:
library(tidyverse)
library(ggord)
# prcomp
ord <- prcomp(dat[, 1:4])
# add PCA vectors to plot as separate geom
dat <- dat %>%
mutate(
one = ord$x[, 'PC1'],
two = ord$x[, 'PC2'],
newgrp = sample(c('a', 'b'), n(), replace = T)
)
# make ggord, remove points layer
p <- ggord(ord, dat$Species)
p$layers[[1]] <- NULL
# add points layer manually, redefine some aesthetics
p + geom_point(data = dat, aes(shape = newgrp, colour = Species, group = newgrp), size= 4, alpha = 0.5) +
scale_shape_manual(values = c(16, 17)) +
guides(fill = guide_legend(override.aes= list(shape = NA))) +
theme(legend.title = element_blank())
Excellent, thank you!! This allowed me to highlight one specific group of interest in my NMDS.
Issues
Any issues or feature requests can be posted on the issues page. Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or send me a direct message.
Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.
Brief description of the problem