0
하나의 막대가 지정된 색상으로 구별되는 ggplot2로 막대 차트를 만들고 싶습니다.geom_bar를 사용하는 ggplot - 색상으로 단일 막대 구별
type <- c('apples','pears','bananas','plums','melons','pineapples')
weight <- c(14,11,19,16,12,8)
fruit <- data.frame(type,weight)
이 내가 플롯을 생산하기 위해 지금까지 무엇을 가지고 :
는 간단한 데이터 프레임 설명하기 위해library("ggplot2")
f <- ggplot(fruit, aes(x=type, y=weight))
f + geom_bar(stat=’identity", fill = (ifelse(fruit$type=='bananas', 'yellow', 'gray')))
OK, 그래서 문제가 무엇 : 우리는 요인의 수준은 바나나가 있음을 필요로하기 때문에
, 작동은 다음과의 마지막 줄을 교체? (""대신에'''를 제외하고) – Axeman
바나나라면 '멜론'이 노란색으로 채워진다. – Curious56
아, 괜찮아.'f + geom_col (aes (fill = ifelse $ type == 'bananas', 'yellow', 'gray'))) + scale_fill_identity()' – Axeman