0
我有这样如何使混凝土热图值
df<- structure(list(name = structure(c(2L, 12L, 1L, 16L, 14L, 10L,
9L, 5L, 15L, 4L, 8L, 13L, 7L, 6L, 3L, 11L), .Label = c("All",
"Bab", "boro", "bra", "charli", "delta", "few", "hora", "Howe",
"ist", "kind", "Kiss", "myr", "No", "TT", "where"), class = "factor"),
value = c(1.251, -1.018, -1.074, -1.137, 1.018, 1.293, 1.022,
-1.008, 1.022, 1.252, -1.005, 1.694, -1.068, 1.396, 1.646,
1.016)), .Names = c("name", "value"), class = "data.frame", row.names = c(NA,
-16L))
数据看起来像下面
# name value
#1 Bab 1.251
#2 Kiss -1.018
#3 All -1.074
#4 where -1.137
#5 No 1.018
#6 ist 1.293
#7 Howe 1.022
#8 charli -1.008
#9 TT 1.022
#10 bra 1.252
#11 hora -1.005
#12 myr 1.694
#13 few -1.068
#14 delta 1.396
#15 boro 1.646
#16 kind 1.016
当我绘制它
ggplot(df, aes(x = 1,y = name, fill = value)) +
geom_tile() +
ylab("")
它绘制它随机
但我想要具有与我在数据中一样的顺序。我也想让ylim更小,但我做不到。我很欣赏任何建议
这里不需要'ordered ='。这会创建一个“有序因子”,就像一个有序变量。只是设置的水平是最好的。 – MrFlick
@MrFlick这不起作用。我建议你自己尝试一下。有序确实需要停止ggplot排序水平。 – AlexR
我确实尝试过。 'df $ name < - factor(df $ name,levels = rev(df $ name)); ggplot(df,aes(x = 1,y = name,fill = value))+ geom_tile()+ ylab(“”)'不需要'ordered ='参数。 – MrFlick