Skip to content

view facet label text #4979

@bergsmat

Description

@bergsmat

labeller() and related functionality give huge flexibility for controlling strips, thanks! But I've been asked to write an extension that programmatically modifies strip text font size in the event that a strip has many lines. At present it is hard to examine strip text in advance. Apparently labeller() is called once during build_strip() and the result is immediately rendered as grobs. Stealing ideas from https://github.com/yjunechoe/ggtrace I can do invisible(ggplotGrob(x)) while running trace() on build_strip(), but the latter is not exported so there is going to be a package check warning that will probably keep the solution from ever posting on CRAN.

I completely understand if you do not want to export build_strip(). Is there an alternative way, existing or otherwise (feature request), to view the facet label text of a ggplot object before rendering?

debug(ggplot2:::build_strip) # labels near line 12
ggplot(mtcars, aes(wt, mpg)) + geom_point() + facet_grid(cyl ~ am + gear)

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