Skip to content

Strip aesthetics inconsistency with facet_grid using switch="y" #3061

Closed
@touala

Description

@touala

I have an issue with strip border aesthetics when using facet_grid(..., switch="y") in both ggplot2 version 2.2.1 and 3.1.0. In the example below, border size is different between x and y strip.

df <- data.frame(x=c(1,1,1,1), y=c(1,1,1,1), grp1=c("A","A","B","B"), grp2=c("C","D","C","D"))
ggplot(df) +
	geom_point(aes(x=x,y=y)) +
	facet_grid(grp1~grp2) +
	theme(strip.background=element_rect(colour="black"))
ggplot(df) +
	geom_point(aes(x=x,y=y)) +
	facet_grid(grp1~grp2, switch="y") +
	theme(strip.background=element_rect(colour="black"))

The other element_rect parameters (fill, linetype, and color) do not display the same behavior and facet_grid(..., switch="x") work as expected.

ggplot(df) +
	geom_point(aes(x=x,y=y)) +
	facet_grid(grp1~grp2, switch="x") +
	theme(strip.background=element_rect(colour="black"))

In 3.1.0, I can correct y strip border size independently using theme(strip.background.y=element_rect(...)) but it's not practical (see below).

ggplot(df) +
	geom_point(aes(x=x,y=y)) +
	facet_grid(grp1~grp2, switch="y") +
	theme(strip.background=element_rect(colour="black")) +
	theme(strip.background.x=element_rect(size=0.5), strip.background.y=element_rect(size=0.25))

Also note that strip border has round outside corner with facet_grid(..., switch="y"), which is not consistent with other configurations.

Let me know if you have questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions