,今天重复这个热图
这个图具体的数据是什么意思暂时还没太看明白,最终用于作图的数据格式如下
image.png
前半部分准备数据的代码这里就不介绍了
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