Closed RvV1979 closed 3 months ago
Hi @RvV1979,
Thanks for your suggestion. I have thought about this before and so far I've decided not to include such an option. The main rationale for this is that users will have so many different requirements on where they want to position labels and how they want to style the labels that I think it will bloat the mapmixture()
function. Also, because the output of mapmixture is a ggplot
object, it is fairly straightforward to add your own labels next to the pies using the same coordinates data frame and geom_text
or geom_label
.
For example, to add labels above each pie you could increase your latitude coordinates by a given amount:
library(mapmixture)
library(ggplot2)
file <- system.file("extdata", "admixture1.csv", package = "mapmixture")
admixture1 <- read.csv(file)
file <- system.file("extdata", "coordinates.csv", package = "mapmixture")
coordinates <- read.csv(file)
map1 <- mapmixture(admixture1, coordinates)+
geom_label(
data = coordinates,
mapping = aes(label = substr(Site , 1, 3), x = Lon, y = Lat + 0.8),
size = 3, label.size = 0.25, label.padding = unit(0.05, "cm")
)
ggsave(plot = map1, filename = "mapmixture.png", device = png, type = "cairo", units = "in", width = 6, height = 8, dpi = 600)
Hi Tom, Thanks for the fast response. I understand your motivations for not including this as an option. Your example of how to add labels above each pie help a lot. Best wishes
Just a suggestion: to add an option to plot the site labels next to the pie charts to allow for easy referencing.
Thanks