I want to create a graph from two series “Pos” and “Neg” (y values) from a data frame. The x value is in the Medium column. I want the series to have a different color.
A stackoverflow search gave me a similar question: change the color for two geom_point () in ggplot2 , but I want to use aes_string to avoid notes when checking the package.
I get it to work using ice and “automatic” colors, as in the first example below. However, I cannot figure out how to create the same plot using aes_string and still allow ggplot colors. I feel it should just be ...
Playable example:
exData <- data.frame(Marker = rep("TH01", 10),
Mean = seq(1:10),
Neg = -1*runif(10,0.1,1),
Pos = runif(10,0.1,1))
gp <- ggplot(exData, aes_string(x="Mean"),
shape=val_shape, alpha=val_alpha)
gp <- gp + geom_point(aes(y=Pos, colour="Max"))
gp <- gp + geom_point(aes(y=Neg, colour="Min"))
gp <- gp + scale_colour_discrete(name = "Legend")
print(gp)
gp <- ggplot(exData, aes_string(x="Mean"),
shape=val_shape, alpha=val_alpha)
gp <- gp + geom_point(aes_string(y="Pos"), colour=1)
gp <- gp + geom_point(aes_string(y="Neg"), colour=2)
gp <- gp + scale_colour_discrete(name = "Legend")
print(gp)