0

I am able to plot data and and everything seems to work. The only problem is that R seems to decide if line markers are inserted or not. I have several different datasets, for the dataset with 1500 the plot works fine and I can see the markers. Any other dataset, all of them with 3000+ points the plot ignores all markers and just the line can be seen. Bellow you guys can see the code used to plot the data and example plot Figures.

My question is, how can I assure that R will plot the lines with markers? Am I doing something wrong?

Thanks for your time and help.

png(filename="figures/all.normdtime.png", width=800, height=600)
plot(ecdf(data1[,10]), col="blue", ann=FALSE,       pch=c(1,NA,NA,NA,NA,NA,NA,NA,NA), cex=2) 
lines(ecdf(data2[,10]), col="green", pch=c(3,NA,NA,NA,NA,NA,NA,NA,NA), cex=2)
lines(ecdf(data3[,10]), col="red", pch=c(8,NA,NA,NA,NA,NA,NA,NA,NA), cex=2)
lines(ecdf(data4[,10]), col="orange", pch=c(2,NA,NA,NA,NA,NA,NA,NA,NA), cex=2)

title(xlab="Transfer rate (bytes/ms)")
title(main="ECDF Normalized Download Time")

dev.off()

No markers, 21100 points plotted

With markers, 1400 points plotted

  • Does it really make sense to use the custom pch's if you have that many points? Not sure if it is visually appealing – Martin Schmelzer Oct 07 '15 at 17:11
  • I decrease the amount of time that the points are shown, as you can see from the pch=c(3,NA,NA,NA,NA,NA,NA,NA,NA) part. But you gave me an idea. I will try to decrease it even more and see what happens :) – Moises Rodrigues Oct 07 '15 at 17:12
  • No difference, still no markers shown. Although, The figure with 1400 points looks better. – Moises Rodrigues Oct 07 '15 at 17:19

1 Answers1

0

I would try something like this:

data1 <- dnorm(seq(-5,5,.001))
x <- ecdf(data1)

plot(ecdf(data1), col="blue", ann=FALSE, pch=c(1,rep(NA,10000)), cex=2) 
points(x=knots(x)[seq(1,length(knots(x)),5)], y=ecdf(data1)(knots(x)[seq(1,length(knots(x)),5)]), col="red",pch=3)

title(xlab="Transfer rate (bytes/ms)")
title(main="ECDF Normalized Download Time")

enter image description here

The original ECDF is not visible since we plotted approx. 1500 points. If you want less just change the value 5 inside the x and y argument of pointsto a bigger number i.e. 100. Then we have ~70 points plotted:

enter image description here

I don't have your data available but I think this should work for you:

ecdf1 <- ecdf(data1[,10])
ecdf2 <- ecdf(data2[,10])
ecdf3 <- ecdf(data3[,10])
ecdf4 <- ecdf(data4[,10])

knots1 <- knots(ecdf1)
knots2 <- knots(ecdf2)
knots3 <- knots(ecdf3)
knots4 <- knots(ecdf4)

n <- 10 # every 10th point

png(filename="figures/all.normdtime.png", width=800, height=600)

plot(ecdf1, col="blue", ann=FALSE) 
points(x=knots1[seq(1,length(knots1),n)], y=ecdf1(knots1[seq(1,length(knots1),n)]), col="blue",pch=1)

lines(ecdf2, col="green")
points(x=knots2[seq(1,length(knots2),n)], y=ecdf2(knots2[seq(1,length(knots2),n)]), col="green",pch=3)

lines(ecdf3, col="red",)
points(x=knots3[seq(1,length(knots3),n)], y=ecdf3(knots3[seq(1,length(knots3),n)]), col="red",pch=8)

lines(ecdf4, col="orange")
points(x=knots4[seq(1,length(knots4),n)], y=ecdf4(knots4[seq(1,length(knots4),n)]), col="orange",pch=2)


title(xlab="Transfer rate (bytes/ms)")
title(main="ECDF Normalized Download Time")

dev.off()
Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98
  • Awesome! Works perfectly for me. I did some changes because I am using the same code to plot big and small datasets and everything looks amazing. Thanks a lot for the help and the instantaneous response :) – Moises Rodrigues Oct 07 '15 at 18:15