cut off density plot in ggplot2

ggplot2, r

Solution

According to the ggplot2 book, you use `scale_x_continuous(limits=c(1,20))` instead of `xlim(1,20)` for that.

Problem

I use ``` frame <- read.table(paste('data', fname, sep="/"), sep=",", header=TRUE) colnames(frame) <- c("pos", "word.length") plot <- ggplot(frame, aes(x=pos, y=word.length)) + xlim(0,20) + ylim(0,20) + geom_density2d() + stat_density2d(aes(color=..level..)) png(paste("graphs/", fname, ".png", sep=""), width=600, height=600) print(plot) dev.off() ``` to create plots, but they get cut off. How do I fix this? http://ompldr.org/vZTN0eQ The data I used to create this plot: http://sprunge.us/gKiL

Original source