inst/examples/image242-tikz.R

# ggplot2 绘制颜色图中色块与数值的对应关系
x = matrix(sample(24), 8)
p = ggplot(transform(expand.grid(h = 1:8, v = 1:3), z = as.vector(x)),
       aes(x = h, y = v)) +
  geom_tile(aes(fill = z)) +
  scale_fill_distiller(palette="YlOrRd", name = "$z$") +
  geom_text(aes(label = z)) +
  theme_void()
print(p)
yihui/MSG documentation built on Aug. 16, 2021, 12:13 p.m.