Closed dansmith01 closed 2 years ago
In {ggpattern}
the default resolutions for the main pattern and the legend key are different but you can override the default resolution for both with ggpattern_res
global option. Doing so seems to work better for the "magick"
patttern. For example your same chart with options(ggpattern_res = 60)
(set default resolution of 60 pixels per inch):
Thanks @trevorld!
After poking through the code, I noticed setting pattern_res
worked too.
ggplot(data.frame(x=LETTERS[1:3], y=1:3)) +
geom_bar_pattern(aes(x=x, y=y, pattern_type=x), color="black", fill="white", pattern="magick", stat="identity", pattern_res=72) +
scale_pattern_type_discrete(choices = c('bricks', 'fishscales', 'right45')) +
theme(legend.key.size = unit(4, "lines"))
Bug description
The
magick
package's built-in patterns look great in the plot itself, but are distorted in the legend.I realize you've noted this in the README's "Limitations" section as "Legend rendering for patterns is still not great. Use
pattern_key_scale_factor
to adjust legend appearance." I wanted to bring it up as an issue to see a fix can be found. The suggested workaround of usingpattern_key_scale_factor
doesn't seem to make it any difference, other than increasing the rendering time.I'll start looking into a fix myself and submit a PR if successful; any kind of direction you can give would be appreciated.
Session info All packages are current as of this posting - 12/9/2021