Reputation: 13
I need to plot a heatmap of mean values. It is pretty straightforward.
ggplot(data, aes(x=var1, y=var2, z=var3)+
stat_summary_2d(fun=“mean“,geom="tile")
I need a text above the tiles representing same values.
I tried,
+stat_summary_2d(fun="mean", geom="text")
but it requires label aesthetic and I don't know what to write there.
Upvotes: 1
Views: 892
Reputation: 17299
You can access the computed variable at each cell with ..value..
. As you didn't provide data, below is an example using diamonds
dataset:
library(ggplot2)
ggplot(diamonds, aes(carat, depth, z = price)) +
stat_summary_2d(fun = 'mean') +
stat_summary_2d(aes(label = ..value..), fun="mean", geom="text")
Upvotes: 1