切断ggplot2中的密度图

Rea*_*onk 5 r ggplot2

我用

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()
Run Code Online (Sandbox Code Playgroud)

创造情节,但他们被切断了.我该如何解决?

http://ompldr.org/vZTN0eQ

我用来创建这个图的数据:http://sprunge.us/gKiL

Rea*_*onk 7

根据 ggplot2 书,您使用scale_x_continuous(limits=c(1,20))代替xlim(1,20)