3

How can I generate a plot like the following in R.

enter image description here

It shows the percent of transactions (x) for a given response time (y), see my own answer below for my own go at it.

oluies
  • 17,694
  • 14
  • 74
  • 117

2 Answers2

15

Methinks you want a plot of an empirical cumulative distribution function.

So take a look at the documentation for ecdf() as well as the more featureful Ecdf() in the CRAN package Hmisc.

Hmisc Ecdf example: ExecTm array of execution times, HttpProvCall array of time it took to call downstream system and we compare the time we spend with the downstream system with percentiles

> library(Hmisc)
> x <- c(ExecTm,ExecTm-HttpProvCall)
> g <- c(rep('ExecTm',length(ExecTm)),rep('ExecTm-HttpProvCall',length(ExecTm)))
> Ecdf(x, group=g, xlab='Test Results', 
+     label.curves=list(keys=1:2),q=c(.90,.95,.98))

enter image description here

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • I just had a short look at the online help to `ecdf` to be sure and, whoops, there is the answer. On stackoverflow it pays to post first and think second if you want to gain points :) (btw +1) – Henrik Jun 08 '11 at 17:24
0

y <- c(rnorm(8000, 300, 10), rnorm(400, 500, 300) )

t2 <- quantile(y, probs = seq(0, 99.99, by=.1)/100)

plot(t2, xlab="promille ", ylab="time (ms)",pch=20)

gives me:

enter image description here

whit my dataset

enter image description here

Community
  • 1
  • 1
oluies
  • 17,694
  • 14
  • 74
  • 117