Home > Back-end >  How to draw histogram without the vertical lines in common between bars?
How to draw histogram without the vertical lines in common between bars?

Time:04-10

hist generates a histogram with the vertical boundaries of bars plots. If I don't want to draw the vertical boundaries that are common between adjacent bars, is there a way to do so?

CodePudding user response:

If you want to retain the outline, it's pretty trivial to draw a polygon over the histogram:

set.seed(1)
h <- hist(rnorm(50))

enter image description here

polygon(rep(h$breaks, each = 2), c(0, rep(h$counts, each = 2), 0), col = "gray")

enter image description here

CodePudding user response:

First some reproducible data:

set.seed(42)
x <- rnorm(100, 15, 4)

The border= argument is documented on the manual page for hist (?hist):

hist(x, border="lightgray")

No border. Barplot

  •  Tags:  
  • r
  • Related