简体   繁体   中英

R comulative distribution charts

I'm quite a beginner at using R for visualization of data. I've generated comulative distribution chart with following code:

if (length(first$dtl) > 0) {first_cdf <- ecdf(first$dtl)} else first_cdf <- 0
cdf_range <- range(0, first$dtl, na.rm=TRUE)
plot(first_cdf, main="Distribution", xlab="Values", xlim=cdf_range, col="#76B727", cex.axis=0.8, pch=20)

With this I get

在此处输入图片说明

Now issue is that I would like to get clear line instead of dots connected with line. I've tried to change pch as well as lty parameter, but it seems there is no way to get clear line with those. Any idea how to solve this issues?

Thank you and best regards!

This disables the dots and adds vertical lines to make it continuous:

set.seed(1)
plot(ecdf(rnorm(100)), do.points=FALSE, verticals=TRUE)

在此处输入图片说明

Type plot.ecdf in at the R prompt to see the full function or ?plot.ecdf for the help file (which directs further to ?plot.stepfun ). Even though you are calling vanilla plot , the plot.ecdf function is what's used, thanks to R's method dispatch, ?Methods .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM