Home > Back-end >  In geom_tile(), how to change vertical or horizon border color of the cell
In geom_tile(), how to change vertical or horizon border color of the cell

Time:05-14

In geom_tile(), how to change vertical or horizon border color of the cell ?

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()

enter image description here

CodePudding user response:

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())
  • Related