2016-04-23 9 views
0

Meine Füllung ist ein Farbverlauf und ich möchte jede Zelle mit unterschiedlicher Farbe proportional zur vorbereiteten Verteilung färben.Versuch, Holdem Hand Bereich mit prozentualer Verteilung zu visualisieren

Mein Grundstück:

My Plot

Plot, die ich hinzufügen möchten:

Plot that I want to add

Mein Code:

ggplot(dat, aes(Var1, Var2)) + 
geom_tile(aes(fill = w[trans[dat$value]]), color = "gray") + 
geom_text(aes(label = pairs$hole_cards[trans[dat$value]])) + 
scale_fill_gradient(low = mincolor, high = maxcolor) + 
coord_fixed() + 
theme(axis.line=element_blank(),axis.text.x=element_blank(), 
axis.text.y=element_blank(),axis.ticks=element_blank(), 
axis.title.x=element_blank(), 
axis.title.y=element_blank(),legend.position="none", 
panel.background=element_blank(),panel.border=element_blank(),panel.grid.major=element_blank(), 
panel.grid.minor=element_blank(),plot.background=element_blank(),plot.title = element_text(size=20)) 

Antwort

0

Sie könnten tun

set.seed(1) 
df <- cbind(
    within(as.data.frame(replicate(2, sample(1:50,4*4,T)/100)), V3 <- 1-V2-V1), 
    expand.grid(1:4, 1:4) 
) 
head(df) 
#  V1 V2 V3 Var1 Var2 
# 1 0.14 0.36 0.50 1 1 
# 2 0.19 0.50 0.31 2 1 
# 3 0.29 0.20 0.51 3 1 
# 4 0.46 0.39 0.15 4 1 
# 5 0.11 0.47 0.42 1 2 
# 6 0.45 0.11 0.44 2 2 
library(ggplot2) 
i <- .47 
ggplot(df, aes(Var1, Var2)) + 
    geom_tile() + 
    geom_rect(fill="red", aes(xmin=Var1-i, xmax=Var1-i+V1, ymin=Var2-i, ymax=Var2+i)) + 
    geom_rect(fill="darkgreen", aes(xmin=Var1-i+V1, xmax=Var1-i+V1+V2, ymin=Var2-i, ymax=Var2+i)) + 
    geom_rect(fill="yellow", aes(xmin=Var1-i+V1+V2, xmax=Var1+i, ymin=Var2-i, ymax=Var2+i)) + 
    geom_text(aes(label=paste(Var1, Var2, sep=","))) 

![enter image description here

+0

wow! tolle! ich danke dir sehr –