Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
touala opened this issue Jan 8, 2019 · 5 comments
Closed

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

touala opened this issue Jan 8, 2019 · 5 comments
Labels

Comments

@touala
Copy link

@touala touala commented Jan 8, 2019

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.

@karawoo
Copy link
Member

@karawoo karawoo commented Jan 9, 2019

Adding a reprex to show the plots:

library("ggplot2")

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"))

Created on 2019-01-09 by the reprex package (v0.2.1)

The last time I saw something like this it was due to clipping being turned off, and was fixed in this commit. I'll try to look into that when I get a chance, maybe the fix isn't getting carried through when the strip position is switched.

@karawoo karawoo added the bug label Jan 9, 2019
@touala
Copy link
Author

@touala touala commented Jan 10, 2019

Ok, I did not realize I could directly embed plots with reprex. I will do it next time.

Good luck fixing that.

@clauswilke
Copy link
Member

@clauswilke clauswilke commented Jan 10, 2019

Related? #2772

I agree this looks like a clipping issue. I had a look at the code when #2772 was filed and couldn‘t immediately figure out where clipping goes wrong. It‘s not obvious.

@karawoo
Copy link
Member

@karawoo karawoo commented Jan 19, 2019

Closed in #3068

@karawoo karawoo closed this Jan 19, 2019
@lock
Copy link

@lock lock bot commented Jul 18, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants