r - ggplot's stat_ecdf adds two extra points -


in ggplot2, when try plot cumulative density function using stat_ecdf , geom_point, see strange behavior: 2 points added numbers, 1 before everything, , 1 after else. kind of make sense if default geom_step used plotting, geom_point, confusing if not outright wrong. know how fix this?

here example:

qplot(a,data=data.frame(a=1:10),stat="ecdf",geom="point") 

which produces:

ecdf plot 1 point point @ 0 , 1 @ one

note points @ 0 , @ 10.

here r session info:

> sessioninfo() r version 3.1.1 (2014-07-10) platform: x86_64-apple-darwin13.1.0 (64-bit) ...  attached base packages: [1] stats     graphics  grdevices utils     datasets  methods   base other attached packages: [1] scales_0.2.4  ggplot2_1.0.0 

it doesn't sense apply stat_cdf geom_point(). if want cdf plot, better off with.

library(ggplot2) df = data.frame(a=1:10) ggplot(data = df, aes(x=a)) + stat_ecdf() + scale_x_discrete(breaks = 1:11) 

enter image description here

stat_ecdf supposed step function.

if insist on making code work , accept hack-around, can this.

ggplot(data = df, aes(x=a)) + geom_point(stat = "ecdf", colour = c(rep("red", 11), na)) 

enter image description here


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -