Dinesh
Dinesh

Reputation: 2204

CDF beyond range of values in R ggplot2

I am trying to plot the CDF using ggplot2 in R and I get the following plotenter image description here

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

Answers (1)

IRTFM
IRTFM

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)

enter image description here

Upvotes: 5

Related Questions