Open pyite opened 2 years ago
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?
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
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.
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...
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.
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
.
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