Cut density graph in ggplot2

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 stories, but they are cropped. How to fix it?

http://ompldr.org/vZTN0eQ

The data I used to create this graph is: http://sprunge.us/gKiL

+4
source share
1 answer

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

+3
source

Source: https://habr.com/ru/post/1416185/


All Articles