Reputation: 2204
I am trying to plot the CDF using ggplot2 in R and I get the following plot
But the min and max values of the data are 1947 and 2017. I do not want the line to be plot beyond the ranges [1947, 2017].
ggplot(df, aes(x=year)) + stat_ecdf(geom="line") + xlab("Year") + xlim(1947, 2017)
Can anyone help with this issue?
Upvotes: 2
Views: 248
Reputation: 263301
Try using the pad parameter with FALSE value:
ggplot( data.frame(x=1947:2017), aes(x=x)) + stat_ecdf(geom="line", pad=FALSE)
Upvotes: 5