'Colouring histogram splits it up

When I add an outline colour to my histogram, and fill in the colours it looks like this: enter image description here

Here's the code that I am using:

ggplot(mtcars, aes(as.character(cyl), log(hp), fill = as.character(cyl))) + 
    geom_col(colour=1,alpha = 0.75) +
    scale_fill_manual(values = c("gray", "red", "blue"))

How can I remove the horizontal lines for each plot so it remains as a single block with one colour? When I remove colour=1 I get what I'm after, but I need the black colour outlines for each block.



Solution 1:[1]

I suggest using stat_summary instead, and making use of fun = "sum"

ggplot(mtcars, aes(as.character(cyl))) + 
  stat_summary(aes(y = log(hp), fill = as.character(cyl)), fun = "sum", geom = "bar", colour = "black") +
  scale_fill_manual(values = c("gray", "red", "blue"))

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gnueghoidune