I recently updated R and ggplot2 to the versions (4.1.1 and 3.3.5 respectively). I was using this code to create plots in ggplot:
rejA<-c(0.05,0.10,0.00,0.05)
Tr<-c("Corn\nmale\nx\nCorn\nfemale","Corn\nmale\nx\nWheat\nfemale","Wheat\nmale\nx\nCorn\nfemale","Wheat\nmale\nx\nWheat\nfemale")
Matingdiet<-c("Same diet","Different diets","Different diets", "Same diet")
d<-as.data.frame(cbind(Tr,rejA,Matingdiet))
d$rejA<-as.numeric(as.character(d$rejA))
d$Matingdiet<-factor(d$Matingdiet,levels = rev(levels(d$Matingdiet)))
mycol<-RColorBrewer::brewer.pal(9,"YlOrBr")[c(7,4)]
dev.new()
pl<-ggplot(data = d, aes(x=Tr, y=rejA))+
geom_col(aes( fill=Matingdiet))+
labs(x = "Mating pairs",fill="Male and female from", y = "Proportion of mates rejected")+
scale_y_continuous(limits=c(0,1),expand = c(0,0))+
scale_fill_manual(values=mycol)+
theme_bw() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.y = element_line(colour = "black"),
axis.text=element_text(size = 10),
strip.background = element_blank(),
axis.text.y=element_text(size = 10),
panel.border=element_blank(),
panel.spacing.x = unit(1,"line"),
strip.text.x = element_text(size = 20))+
geom_hline(yintercept = 0)
pl
However, the colors are not showing up in the graph. I used the same code earlier to get this plot

However, now when I run the same code, all the bars are grey and there is no legend.
I have tried changing the colours in the code
pl<-ggplot(data = d, aes(x=Tr, y=rejA))+
geom_col(aes( fill=Matingdiet))+
labs(x = "Mating pairs",fill="Male and female from", y = "Proportion of mates rejected")+
scale_y_continuous(limits=c(0,1),expand = c(0,0))+
scale_fill_manual(values=c("red","blue"))+
theme_bw() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.y = element_line(colour = "black"),
axis.text=element_text(size = 10),
strip.background = element_blank(),
axis.text.y=element_text(size = 10),
panel.border=element_blank(),
panel.spacing.x = unit(1,"line"),
strip.text.x = element_text(size = 20))+
geom_hline(yintercept = 0)
pl
This also return a graph with all bars in grey. I am not sure what to try now, especially since it was working earlier (in R version 3.5).