在 geom_tile() 中,如何更改单元格的垂直或水平边框颜色
In geom_tile(), how to change vertical or horizon border color of the cell
在geom_tile()中,如何改变单元格的垂直或水平边框颜色?
library(tidyverse)
month <- c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10)
category <- c("A","B","A","B","A","B","A","B","A","B","A","B","A","B","A","B","A","B","A","B")
sales <- c(10,8,25,21,10,20,25,30,27,8,1,4,9,24,17,6,17,10,5,7)
plot_data <- data.frame(month,category,sales)
plot_data %>% ggplot(aes(x=factor(month),y=category,fill=sales))+
geom_tile()
plot_data %>% ggplot(aes(x=factor(month),y=category,fill=sales))+
geom_tile() +
geom_vline(xintercept = 1.5, color = "white") +
geom_vline(xintercept = 2.5, color = "white") +
geom_vline(xintercept = 3.5, color = "white") +
geom_vline(xintercept = 4.5, color = "white") +
geom_vline(xintercept = 5.5, color = "white") +
geom_vline(xintercept = 6.5, color = "white") +
geom_vline(xintercept = 7.5, color = "white") +
geom_vline(xintercept = 8.5, color = "white") +
geom_vline(xintercept = 9.5, color = "white") +
theme(panel.background = element_blank())
在geom_tile()中,如何改变单元格的垂直或水平边框颜色?
library(tidyverse)
month <- c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10)
category <- c("A","B","A","B","A","B","A","B","A","B","A","B","A","B","A","B","A","B","A","B")
sales <- c(10,8,25,21,10,20,25,30,27,8,1,4,9,24,17,6,17,10,5,7)
plot_data <- data.frame(month,category,sales)
plot_data %>% ggplot(aes(x=factor(month),y=category,fill=sales))+
geom_tile()
plot_data %>% ggplot(aes(x=factor(month),y=category,fill=sales))+
geom_tile() +
geom_vline(xintercept = 1.5, color = "white") +
geom_vline(xintercept = 2.5, color = "white") +
geom_vline(xintercept = 3.5, color = "white") +
geom_vline(xintercept = 4.5, color = "white") +
geom_vline(xintercept = 5.5, color = "white") +
geom_vline(xintercept = 6.5, color = "white") +
geom_vline(xintercept = 7.5, color = "white") +
geom_vline(xintercept = 8.5, color = "white") +
geom_vline(xintercept = 9.5, color = "white") +
theme(panel.background = element_blank())