Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading