Skip to content

Annotate all facets with axis ticks and labels for fixed scales #4064

@clauswilke

Description

@clauswilke

By default, interior facets are not drawn with axis ticks or labels.

library(ggplot2)

df <- data.frame(
  x = rnorm(900),
  y = rnorm(900),
  a = rep(letters[1:9], each = 10)
)

ggplot(df, aes(x, y)) +
  geom_point() +
  facet_wrap(vars(a))

However, if we set scales = "free", we do get per-facet axis ticks and labels, but now each facet also has its own scale range.

ggplot(df, aes(x, y)) +
  geom_point() +
  facet_wrap(vars(a), scales = "free")

I find that it's often desirable to have fixed scales but have each facet have its own axis annotations. This can currently be achieved by setting scales = "free" but then manually setting the scale limits.

ggplot(df, aes(x, y)) +
  geom_point() +
  facet_wrap(vars(a), scales = "free") +
  xlim(-4, 4) + ylim(-4, 4)

I think it would be a good idea to add an option that draws axis annotations for all facets even if scales are fixed. I routinely wish I had this option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions