My data basically looks like this:
Populations alpha SE Z sample color
Pop1 0.02 0.003 7 9 red
Pop2 0.03 0.003 10 9 red
Pop3 0.02 0.003 11 8 blue
Pop4 0.03 0.003 14 10 green
and I and am plotting as point estimates with error bars. I am having difficulty getting ggplot2 to read my colors.
read.table("table.txt", header = TRUE) -> tbl
require(ggplot2)
tbl$Populations2 <- factor(tbl$Populations, as.character(tbl$Populations))
#pdf(file="table.pdf", width=11)
ggplot(tbl, aes(y = Populations2, x = alpha, xmin = alpha -
SE, xmax = alpha + SE, label = Populations2, colour =
color)) + geom_point(colour = "black") + geom_text(hjust = 1.2) +
theme_classic() + theme(axis.title = element_blank(), axis.ticks =
element_blank(), axis.text.y = element_blank(), legend.position =
"none") + geom_errorbarh(height = .1)
#dev.off()
When I run the code, the pops with the same color listed in the input end up being the same color, but they do not become the color I want them to be. I have tried this with the colors in quotes as well as with the colors listed in hexadecimal, but I get the same problem either way. Any idea how to fix this?