6 jun

How to create a y axis in log2(n) format in R

I want to create a Line Chart in R, I have the y axis representing execution time and I want to represent the y axis as log2(t) where t is the is the time, I have two lines that I want to draw (method1 execution time, method2 execution time). How can I make the y asix goes from 0 to log2 of the maximum execution time of both methods? I followed this thread and here what I have

  method1<-c(1.49, 2.56, 3.98, 7.88)
  method2<-c(1.05, 2.87, 4.01, 7.96)
  x <-c("1","2","4","8")
  y <- range(0, method1+1, method2+1)
  plot(log2(method1), type="o", pch=16, lty=2, col="blue", ylim=y, axes=FALSE, ann=FALSE)
  axis(1, at=1:4, lab=x, cex.axis=0.65)
  axis(2,las=1, at=log2(lab+1),labels=lab,cex.axis=0.65)
  lines(log2(method2), type="o", pch=15, lty=2, col="red")

I do not get the correct results, the maximum value in my line chart should be log2(7.96) = 2.992768. This is the picture I get

enter image description here



© 2017 website by Rubit Corporation