Hello i am new to ggplot and i observed a strange behavior. 

I want to display two groups of points, each group with a different color. 
But i encountered a problem with the colors. 

Here is a first example: 

dataset <- data.frame(Main = c("A", "A", "B", "B"), Detail = c( "b", "c", "1", 
"2"), resp = runif(4, min = 0.5, max = 1)) 

ggplot(dataset, aes(x = Detail, y = resp)) + 
facet_grid(.~Main, scales = "free_x")+ geom_point(aes( size=6,shape = 
c(16,16,15,15) ),colour="blue")+geom_hline(aes(yintercept=0.25),colour='blue', 
size=2) 

with this code all the point are blue (like the line below) 


But if i try the following code, where my goal is to have the point on the left 
blue and the one on the right red, a problem appears: 

dataset <- data.frame(Main = c("A", "A", "B", "B"), Detail = c( "b", "c", "1", 
"2"), resp = runif(4, min = 0.5, max = 1)) 

ggplot(dataset, aes(x = Detail, y = resp)) + 
facet_grid(.~Main, scales = "free_x")+ geom_point(aes( size=6,shape = 
c(16,16,15,15) 
,colour=c("blue","blue","red","red")))+geom_hline(aes(yintercept=0.25),colour='blue',
 size=2) 

The points have different colors but those colors are pale (dull). You can see 
it by comparing the blue of the points to the blue of the line. 
I guessing i am duing it wrong but i'm stucked with it. 

Do you have suggestions? 

An additional question is that i want to add text along the blue line (which is 
a reference) but i did not understand what geom_text was expecting. 

Thanks for your help! 

Victor 



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to