2
해당 열의 Fill_factor 카운트 값으로 모든 열에 레이블을 지정하고 싶지만 열당 하나 이상의 레이블을 가져올 수 없습니다.레이블 채우기 값이 ggplot2 인
mydata.df <- data.frame(Fill_factor = c("Fill1", "Fill3", "Fill1", "FILL2","Fill1","Fill1","FILL2", "FILL2","FILL3"), Count = c("AA", "BB", "AA", "AA","CC","BB","AA", "BB", "CC"))
q <- qplot(Count, data= mydata.df, fill= Fill_factor, geom="bar", position="fill") # base sub by gene names
q + theme(axis.text.x=element_text(angle=-90, hjust = 1), text = element_text(size=10))
table(mydata.df$Count,mydata.df$Fill_factor)
Fill1 FILL2 Fill3 FILL3
AA 2 2 0 0
BB 1 1 1 0
CC 1 0 0 1
사용 또한 사용 ddply 기능을 가지고 있지만 난 내가 올바른 위치에 (열마다 여러 텍스트) 텍스트 레이블을 배치 할 수 있습니다 어떻게 올바른 위치
mydata.df.count <- ddply(mydata.df, .(Fill_factor, Count), nrow)
colnames(mydata.df.count) <- c("Fill_factor", "Count", "Frequency")
mydata.df.count <- ddply(mydata.df.count, .(Count), transform, pos = cumsum(Frequency)/5) # incorrect position
p = ggplot(mydata.df.count, aes(x = Count, y = Frequency), stat="identity") + geom_bar(aes(fill = Fill_factor), position="fill") + geom_text(aes(label = Frequency, y = pos), size = 5)
p
을 얻는 방법을 알고하지는 position = "fill"인수? 어떻게 필자가 Count의 레벨을 정렬하여 가장 높은 Fill factor == "fill1"카운트를 주문할 수 있습니까?
감사합니다.
: http://stackoverflow.com/search?q=[ggplot2]+ label + stacked + bars + geom_bar – Henrik
누적 막대 그래프에 라벨을 지정하는 방법은 다음과 같습니다. http://stackoverflow.com/questions/6644997/showing-data-values-on-stacked-bar-chart-in-ggplot2 – lukeA
모르겠 음 하지만 난 항상 y와 ymax 인수를 놓치고, 나는 위치 인수와 y 값을 얻는 방법을 모른다. – user3300849