2016-12-12 6 views
0

ここに問題があります。このコードを使用すると:ggplotly stacked area累計ラベルのないプロット

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) 

スタック領域のmyラベルは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

関連する問題