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

Pattern doesn't show up in the legend #86

Open
pyite opened this issue Jun 29, 2022 · 6 comments
Open

Pattern doesn't show up in the legend #86

pyite opened this issue Jun 29, 2022 · 6 comments
Labels
reprex Needs a minimal, reproducible example

Comments

@pyite
Copy link

pyite commented Jun 29, 2022

I have tried more or less every ggpattern + legend example I could find in Google and there doesn't appear to be a way to get the pattern into the legend.

Same bug & software versions as this guy: https://community.rstudio.com/t/stripe-pattern-in-ggplot2-legend/130577

This is on Ubuntu 22.04, which means:
R 4.1.2
ggpattern 0.4.2

I'm not opposed to an ugly workaround to get my graph done... is there a known combination of software versions that works?

Thanks,
Mark

@trevorld
Copy link
Owner

Your issue is not reproducible for me . I see the same (pattern in legend as expected) as ibertchen does in https://community.rstudio.com/t/stripe-pattern-in-ggplot2-legend/130577/2

I'm using R 4.2.1, ggpattern 0.4.3-4 (development version), and Ubuntu 20.04

Are you using x11(type = "cairo") to view the plots?

@pyite
Copy link
Author

pyite commented Jun 29, 2022

I'm using ggsave to write to a png file. I'll try the other method next.

Edit: I tried the above x11 command but the legend pattern is still missing. Sounds like I should try R 4.2.1 next.

Thanks,
Mark

@pyite
Copy link
Author

pyite commented Jun 30, 2022

I installed the 4.2 versions from cloud.r-project.org but still have the missing pattern problem. Weird.

I'll try fresh installs on a couple of distros and see if that gives any clues.

@trevorld
Copy link
Owner

Are you starting R in the terminal with R --vanilla and then copying and pasting the commands from https://community.rstudio.com/t/stripe-pattern-in-ggplot2-legend/130577/2 ?

Besides playing with size of the keys i.e. theme(legend.key.size = unit(2, 'cm')) in {ggplot2} can also play with the pattern_key_scale_factor aesthetic...

@trevorld trevorld added the reprex Needs a minimal, reproducible example label Jul 2, 2022
@dylangomes
Copy link

I was having a similar issue: https://stackoverflow.com/q/75103256/9096420 and playing with the size of the keys theme(legend.key.size = unit(2, 'cm')) did not seem to help at the values I tried, but pattern_key_scale_factor did help. Trial and error landed me at pattern_key_scale_factor=.5 for a pdf of 12 x 9 inches.

@derrik-gratz
Copy link

derrik-gratz commented Mar 29, 2024

I had a similar issue where the legend would sometimes appear with certain figure dimensions but not all. It worked with fig.height=6 and fig.width=8, but not with larger dimensions. I was also able to resolve it with the above suggestion of setting pattern_key_scale_factor=0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex Needs a minimal, reproducible example
Projects
None yet
Development

No branches or pull requests

4 participants