hadley/ggplot2 — Issue #266: x axis labels are centered relative to length of longest label
Author: wch
Created: 2011-11-29 21:39:02+00:00
State: open

In the development version, each label on the x axis seems to be centered relative to the longest label, instead of its own length.

Example:

```
dat <- data.frame(x=c("bar", "foo", "long label"), y=1:3)
ggplot(dat, aes(x=x, y=y)) + geom_point()
```

Here's my attempt at a test case. It looks like there are extra leading spaces added to each short label.

```
library(testthat)
p <- ggplot_build(ggplot(dat, aes(x=x, y=y)) + geom_point())
expect_that(p$panel$ranges[[1]]$x.labels[1], is_identical_to("bar"))
expect_that(p$panel$ranges[[1]]$x.labels[2], is_identical_to("foo"))
```

If there are better ways to write test cases, please let me know.