Skip to content

Feature Request: Warn when axis title or axis label goes outside of the plot area #3282

@billdenney

Description

@billdenney

Related to #3281 (but not the same).

When text goes outside of the plot area, usually the plot is less readable. It would help to have a warning when text goes outside of the plot area. In the example below, the x-axis labels appear to start at "b" and end at "I" because the text is cut off. It would help find unreadable figures if this resulted in a warning-- especially with automated reporting (like in knitr documents).

If implemented, a theme option to suppress the warning would be useful, too. It could be something like theme(warn.outside=TRUE), and it may have variants for warn.outside.axis.text, warn.outside.axis.text.x, warn.outside.axis.text.y, warn.outside.axis.title, warn.outside.axis.title.x, warn.outside.axis.title.y, warn.outside.title, warn.outside.subtitle, warn.outside.caption, and warn.outside.legend.

library(ggplot2)

data_with_long_names <-
  data.frame(
    A=c(paste0(rep(LETTERS, 3), collapse=""), paste0(rep(letters, 3), collapse="")),
    B=1
  )

# Feature request: This gives a warning
ggplot(data_with_long_names, aes(x=A, y=B)) +
  geom_point()

Created on 2019-04-30 by the reprex package (v0.2.0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementguides 📏wipwork in progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions