Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Axis label adjustment with free scales #221

Closed
hadley opened this Issue Aug 10, 2011 · 3 comments

Comments

Projects
None yet
3 participants
Owner

hadley commented Aug 10, 2011

qplot(hwy, reorder(model, hwy), data = mpg) + 
  facet_grid(manufacturer ~ ., scales = "free", space = "free") + 
  opts(strip.text.y = theme_text())
Contributor

BrianDiggs commented Aug 16, 2011

space="free" is not necessary to create this problem. Also, the problem is present on the horizontal axis if the labels are rotated:

qplot(reorder(model, hwy), hwy, data=mpg) +
    facet_grid(. ~ manufacturer, scales="free") +
    opts(axis.text.x = theme_text(angle=90))

It looks like the box for the labels of each facet is being drawn centered in the space which is wide enough for the widest set of labels. However, each box is only wide enough for its own widest label. The tick marks are then put just to the right of this box. Any hjust is also being done with respect to this box. It is especially obvious with

qplot(hwy, reorder(model, hwy), data = mpg) + 
  facet_grid(manufacturer ~ ., scales = "free", space="free") + 
  opts(axis.text.y = theme_text(hjust=0))
qplot(hwy, reorder(model, hwy), data = mpg) + 
  facet_grid(manufacturer ~ ., scales = "free", space="free") + 
  opts(axis.text.y = theme_text(hjust=1))

It is only noticeable with scales="free" (or the appropriate "free_x" or "free_y") because otherwise all facets have the same widest label (since they all have the same set of labels).

@kohske kohske added a commit to kohske/ggplot2 that referenced this issue Aug 16, 2011

@kohske kohske fix a bug of axis label adjustment for facets (#221). 95d8784

@kohske kohske added a commit to kohske/ggplot2 that referenced this issue Aug 16, 2011

@kohske kohske add test code for labels & facets (#221) e6e33e6
Collaborator

kohske commented Aug 16, 2011

wow, the patch commit in folk repository is automatically embedded in this issue thread.

Anyway, probably this bug is fixed, which is tentative (but will be included in 0.9). See the commit.
I'm planning to rewrite guide-axis in more extendable way in the future version.

Owner

hadley commented Dec 2, 2011

Fixed in f5bcca2

@hadley hadley closed this Dec 2, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment