偶然间在github 上发现的这个链接,示例数据和代码都有,很好的R语言学习素材 链接是 https://github.com/blmoore/blogR ,主要内容有
image.png
光看这个可能有些枯燥...大家感兴趣的话可以自己研究研究
我们直接运行画图代码
加载ggplot2
library(ggplot2)
最基本的热图
ggplot(mdf, aes(y=state, x=year, fill=c...)) +
geom_tile()
image.png
调整热图方块的一些内容
ggplot(mdf, aes(y=state, x=year, fill=c)) +
geom_tile(colour...="white",
#linewidth=2,
width=.9,
height=.9)
image.png
这里原来热图对应的小单元格高和宽是都可以调整的...调整热图的颜色和图例
ggplot(mdf, aes(y=state, x=year, fill=c)) +
geom_tile(colour="white",
#linewidth