Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

histogram without vertical lines

Tags:

r

histogram

bin

When I create a histogram, it looks a lot like this:

set.seed(1)
x <- 1:100
y <- x + rnorm(50)
y=round(y)
hist(y)

Is there a way to make a histogram look a bit like this? I can only get a histogram with bins, which I don't need for my plot. heatmap

I don't want the black bins, I actually only want the blue, green and red lines. Can stackoverflow point me in the right direction?

like image 397
Sir Ksilem Avatar asked May 17 '11 12:05

Sir Ksilem


1 Answers

Put your histogram in an object, and use type="s" to get the stepwise plot :

x <- rnorm(1000)
y <- hist(x)
plot(y$breaks,
      c(y$counts,0)
   ,type="s",col="blue")

gives : enter image description here

like image 195
Joris Meys Avatar answered Sep 28 '22 19:09

Joris Meys