我使用
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()
如何创建图表,但它们被截断了。我该如何解决这个问题?
我用来创建此图的数据:http://sprunge.us/gKiL
xlim
和ylim
选项,ggplot会根据你的数据限制为你选择它们。我怀疑你的问题可能就在这里。 - Justinfacet_wrap
或facet_grid
进行绘图并修复比例尺。这样所有的图都在一起,使用同一个比例尺。 - Justinggplot
正在按照您要求的方式进行操作。 您的数据具有3:16
的 y 范围和2:9
的 x 范围,这就是所绘制的内容。 但是,您还告诉ggplot
您希望图形的限制从 0 到 20,这就是您链接的图形显示的内容。 - Justinggplot
会根据提供的数据确定适当的范围。 - Justindensity_2d
将要操作的范围? - Reactormonk