hadley/ggplot2 — pull request #617 by wch (2012-07-11 05:16:52+00:00)
Title: Remove framegrob from guide_axis

This fixes #606, and requires the modified version of gtable.

I ran some timings on it, and with no facets, it's slightly faster than the old version, but with facets, it's slightly slower. All tests were run on installed versions of ggplot2 (not loaded via `load_all`).

For all the test runs, I ran the plots a few times before actually running the test.

## No-facet tests

Here's the code for the no-facet test:

```
n <- 10
times <- numeric(n)
for (i in seq_len(n)) {
t <- system.time(print(ggplot(mtcars, aes(wt,mpg)) + geom_point()))
times[i] <- t[1]
}
times
mean(times)
```

The results for the old version:

```
> times
[1] 0.162 0.157 0.150 0.153 0.158 0.157 0.156 0.150 0.160 0.151
> mean(times)
[1] 0.1554
```

And the results for the new version:

```
d> times
[1] 0.151 0.149 0.140 0.149 0.147 0.158 0.146 0.147 0.144 0.149
d> mean(times)
[1] 0.148
```

Since we're using R, we might as well do a statistical test. :)

```
> t.test(times, times2)

Welch Two Sample t-test

data: times and times2
t = -3.7082, df = 17.804, p-value = 0.001634
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.011595806 -0.003204194
sample estimates:
mean of x mean of y
0.1480 0.1554
```

## Facet tests

This code adds two faceting variables, for a 2x3 grid.

```
n <- 10
times <- numeric(n)
for (i in seq_len(n)) {
t <- system.time(print(ggplot(mtcars, aes(wt,mpg)) + geom_point() + facet_grid(am~cyl)))
times[i] <- t[1]
}
```

Results for the old version:

```
> times
[1] 0.511 0.516 0.492 0.533 0.496 0.480 0.500 0.498 0.500 0.489
> mean(times)
[1] 0.5015
```

And the new version:

```
d> times
[1] 0.521 0.511 0.518 0.498 0.521 0.491 0.563 0.555 0.507 0.516
d> mean(times)
[1] 0.5201
```

And the t-test:

```
> t.test(times, times2)

Welch Two Sample t-test

data: times and times2
t = 2.1526, df = 15.621, p-value = 0.04735
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.0002465331 0.0369534669
sample estimates:
mean of x mean of y
0.5201 0.5015
```