2016-12-12 2 views
0

그래서 여기에 문제가 있습니다. 이 코드를 사용하여 :ggplotly cumsum 레이블이없는 플롯 영역 그림

library(ggplot2) 
library(plotly) 

Values1 <- rep(10, 10) 
Values2 <- rep(20, 10) 
X <- rep(seq(1, 10),2) 
df <- data.frame(Values1=Values1, Values2=Values2) 
df <- melt(df) 
df2 <- data.frame(X=X, Label=df$variable, Value=df$value) 

Plot <- ggplot(data=df2, aes(x=X, y=Value)) + 
    geom_area(data=df2, aes(fill=Label), position='stack') 
ggplotly(Plot) 

누적 된 영역의 내 레이블은 Values1 값보다 Values1 + Values2를 표시합니다.

어떻게 수정합니까?

답변

1

texttooltip을 추가하면 당신이 원하는 당신을 줄 것이다 : 이것은 톤을하는 데 도움이

Plot <- ggplot(data=df2, aes(x=X, y=Value, fill=Label, text = paste("Value:", Value))) + 
geom_area(position='stack') 
ggplotly(Plot) 
ggplotly(tooltip = c("text", "x", "fill")) 
+0

. 매우 감사합니다. – milkmotel