【发布时间】:2016-11-27 20:55:32
【问题描述】:
这是我要绘制的数据:
structure(list(Var1 = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), class = "factor", .Label = c("Specificity", "Dunn Index")), Var2 = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L, 10L, 10L), class = "factor", .Label = c("Variance (2)", "Variance (4)", "Variance & Mean (2)", "Variance & Mean (4)", "Radar Only (2)", "Radar Only (4)", "All Data(2)", "All Data(3)", "All Data Scaled(2)", "All Data Scaled(4)")), value = c(-0.692279597863213, -1.48943741434953, -1.09355531182318, -1.08413861964885, 0.912823257976641, -0.626715742011029, -1.94602923014127, -0.746300681279627, 0.912823257976641, 1.64344717562082, -0.491325775754128, 0.350878495792349, 0.912823257976641, 0.90352725291858, 0.661946945469388, 0.668160073306832, 0.311225652165799, 0.688901920415944, 0.511547544016677, -0.308322460765497, -0.692279597863213, -1.48943741434953, -1.09355531182318, -1.08413861964885, 0.912823257976641, -0.626715742011029, -1.94602923014127, -0.746300681279627, 0.912823257976641, 1.64344717562082, -0.491325775754128, 0.350878495792349, 0.912823257976641, 0.90352725291858, 0.661946945469388, 0.668160073306832, 0.311225652165799, 0.688901920415944, 0.511547544016677, -0.308322460765497), ovals = c(48.41, 42.06, 73.81, 28.57, 73.81, 51.59, 73.81, 69.84, 64.29, 67.46, 5.28412698412698, 11.7253968253968, 8.63095238095238, 33.4107142857143, 18.3043650793651, 76.5388888888889, 36.3634920634921, 52.168253968254, 52.1623015873016, 84.1174603174603, 0.00520833333333333, 0.0164803125616411, 0.0292019422400468, 0.0258761022200942, 0.0923386443151634, 0.0563903328454791, 0.0717603398435939, 0.065214418675562, 0.0657912811602958, 0.0380569462508109, 0.72083903433112, 0.757277684759935, 0.633561928614755, 0.496305437129809, 0.435493681015241, 0.402952149580986, 0.296927697111903, 0.300126336907244, 0.247276928682524, 0.257546088468624)), .Names = c("Var1", "Var2", "value", "ovals"), row.names = c(NA, -40L), class = "data.frame")
这是我的代码:
ggplot(hi.m, aes(Var1, Var2)) +
geom_tile(aes(fill = value)) +
geom_label(aes(label = round(ovals,4)),fill="white",alpha=0.65) +
scale_fill_viridis(name="Scaled\nValue",option="plasma")
我有一个融化的数据框hi.m,其中包含原始值的缩放版本,但我希望原始值成为标签,所以我将它们作为新列添加到hi.m,椭圆形。
这是情节结果,看起来缩放值在未缩放值之上,但它们都被四舍五入到小数点后 4 位:
这是我尝试过的:
- 使用
par(op)重置图形参数 - 将
label放在第一个aes() - 将
fill放在第一个aes() - 删除
geo_tile(两个标签仍然显示)
【问题讨论】: