I would like to plot 2 histograms with pdf's on top of the histogram, but i get the picture as shown in attachment. So, what's wrong with the pdf's? If i draw them on separate graph, everything works. Thanks for the help in advance!

Here is the code:

Code:
par(mfcol=c(2,1))

h1 <- hist(Data$V1,scale="frequency", col="darkgray", xlab="Time per km")
.x <- seq(min(0), max(5), length=100)
g1 <- length(Data$V1)*dgamma(.x, shape=1.312491, scale=0.795368)
remove(.x)
lines(g1,col="red")

h2 <- hist(Data$V1,scale="frequency", col="darkgray", xlab="Time per km")
numSummary(Podatki[,"V1"], statistics=c("mean", "sd", "quantiles"), 
  quantiles=c(0,1))
.x <- seq(min(0), max(5), length=100)
g2 <- length(Data$V1)*dgamma(.x, shape=2.632, scale=1.59542)
remove(.x)
lines(g2,col="purple")