Skip to content

X axis doesn't appear below facet_wrap plot with uneven number of facets #1607

Closed
@paulrougieux

Description

@paulrougieux

When drawing a plot with facet_wrap. If there is an uneven number of facets, the x axis is not drawn for facets which do not touch the "floor" of the plotting area. For example

ggplot(airquality, aes(x = Day, y = Temp)) +
    facet_wrap(~Month) + 
    geom_line()

airquality_facet_wrap

It's possible to add an axis under all plots by setting the scales argument to "free_x".

ggplot(airquality, aes(x = Day, y = Temp)) +
    facet_wrap(~Month, scales = "free_x") + 
    geom_line()

airquatlity_facet_wrap_free_x

But it's not possible to add an x axis only for the last dangling plot alone. This axis could be located in two places, right below the dangling plot:

airquality_facet_wrap_dangling_above

or at the bottom of the plotting area:

airquality_facet_wrap_dangling_below

A workaround was given in this Stackoverflow answer. The author said a suggestion could be submitted here. 2 years after those comments were made on Stackoverflow, no suggestion has been submitted here on github. Considering the number of votes on the workaround answer, the issue still attracts interest. I thought I'd request your feedback. Could this feature be implemented, with minimal change to ggplot2, or is this out of the question?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions