我正在尝试使用ggplots
geom_tile
创建一个热图。就目前而言,网格线位于每个geom_tile
的中间。我想要的是将网格线与每个图块的开始/结尾对齐。我看过一些相关的文章(here,here,但所有文章都涉及连续的标尺。就我而言,两个标尺都是离散的/因子。知道吗?非常感谢!
library(tidyverse)
my_iris <- iris %>%
mutate(sepal_interval=cut(Sepal.Length, 4)) %>%
group_by(sepal_interval, Species)
my_iris %>%
summarise(n_obs=n()) %>%
ggplot()+
geom_tile(aes(y=Species,
x=sepal_interval,
fill=n_obs))+
theme_bw()+
theme(panel.grid = element_line(color="black"))
由reprex package(v0.3.0)在2020-01-28创建