r - Remove extra space beyond xlim and ylim -


i'd make density plot axes right next (or @ least close to) tick marks. seen in mwe, ggplot2 reserved space between tick marks , axes in both x- , y-axis, when have specified xlim , ylim. how can remove them?

with other kinds of plots, seems can call scale_y_continuous(limits=c(0, 100), expand = c(0, 0)) (for example), calling scale_linetype_manual() these parameters doesn't seem anything.

also note in note here drawing axes using geom_segment. there better way this?

set.seed(0) the.df <- data.frame( x = rnorm(800, 50, 10), group = rep(letters[1:8], each = 100))  p <- ggplot(the.df) +      stat_density(aes(x = x, linetype = group), geom = "line", position = "identity") +     xlim(10, 90) + ylim(0, 0.06) +     scale_linetype_manual(values = c("11", "12", "13", "14", "21", "22", "23", "24")) +     geom_segment(aes(x = 10, y = 0, xend = 90, yend = 0)) +     geom_segment(aes(x = 10, y = 0, xend = 10, yend = 0.06))  p 

turns out scale_x_continuous() , scale_x_continuous work. didn't use them correctly earlier.

set.seed(0) the.df <- data.frame( x = rnorm(800, 50, 10), group = rep(letters[1:8], each = 100))  p <- ggplot(the.df) +      stat_density(aes(x = x, linetype = group), geom = "line", position = "identity") +     scale_linetype_manual(values = c("11", "12", "13", "14", "21", "22", "23", "24")) +     scale_x_continuous(limits=c(10, 90), expand = c(0, 0)) +     scale_y_continuous(limits=c(0, 0.06), expand = c(0, 0)) +     geom_segment(aes(x = 10, y = 0, xend = 90, yend = 0)) +     geom_segment(aes(x = 10, y = 0, xend = 10, yend = 0.06))  p 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -