2015-01-10 3 views
0

그래프가 아래에 있는데 왜 그래프에있는 것이 제대로 표시되지 않는지 궁금합니다.R 그래프가 올바르게 표시되지 않음

time<- as.POSIXct(c("2014-12-10 20:51:53.103","2014-12-10 20:56:54.204"), tz= "GMT") 
p<-c(49.32, 60) 
s<-c("B","") 
pointcolor<-c("red","black") 
share<-c(35,0) 
pointsize<-c(1.01,1) 
shapeType<-c(16,10) 
bigDF<-data.frame(time=time, p=p, s=s, pointcolor=pointcolor, share=share, pointsize=pointsize, shapeType=shapeType) 
bigDF 
ggplot(bigDF, aes(x=time, y=p)) + geom_line() + geom_point(aes(shape = as.factor(shapeType),size = pointsize, color = pointsize)) 

실행하면 빨간색으로 표시되지만 turqoise로 표시됩니다. 왜 그런가요?

답변

0

ggplot이 개별 색상 스케일에 사용하는 기본 팔레트 때문입니다. 이 같은 것을 변경할 수 있습니다

ggplot(bigDF, aes(x=time, y=p)) + 
    geom_point(aes(shape = as.factor(shapeType),size = pointsize, color = pointcolor)) 
    scale_color_manual(values = levels(bigDF$pointcolor)) 

levels(bigDF$pointcolor) 
[1] "black" "red" 
0
ggplot(bigDF, aes(x=time, y=p)) + 
geom_line() + 
geom_point(aes(shape = as.factor(shapeType)),size = pointsize, color = pointcolor) 

당신을 정렬 할 곳. aes 호출 안에 color 매개 변수를 넣습니다.

관련 문제