corybrunson / ggalluvial

ggplot2 extension for alluvial plots
http://corybrunson.github.io/ggalluvial/
GNU General Public License v3.0
499 stars 34 forks source link

Adding pattern aesthetic to ggalluvial plot #134

Closed AliceL90 closed 2 months ago

AliceL90 commented 2 months ago

Hi, Thanks a lot for creating this package, it is beautiful! I was wondering if it could be possible to add a feature to the ggalluvial plot. Maybe it is already possible, but I did not manage to do it.

I would like to add pattern to the stratum of interest. I tried to use the aesthetic pattern from ggpattern, but I saw that pattern is not an aestethic accepted by geom_alluvium or geom_stratum.

Is it something that would be possible or of interest to add to the package? I find it can help focusing on specific strata when the plot are a bit busy. Here is an example of what I would like to achieve, using the vaccinations dataset. I have added a pattern with Power Point on the 'Missing' group.

Screenshot 2024-09-23 at 14 49 35
corybrunson commented 2 months ago

Hi @AliceL90, thanks a lot for raising this issue. It's something i'd love to be able to do.

A while back i tried to understand {ggpattern} but didn't get very far. As i understand it, it relies on recreating whole plot layer functions in order to incorporate the pattern fills, and this makes it possible to provide other "image" fills that i think fall outside the core grammar. That is to say, while classic geometric pattern fills make sense to me as a basic {ggplot2} extension that should work well with other extensions, {ggpattern} goes far beyond this, and i'm not prepared to build out {ggalluvial} to match it. I think it would make more sense for someone to make a {ggpattern} extension that introduces alluvial plots.

All that said, i think it would be valuable to have a more core {ggplot2} extension that only provides basic patterns, and that does so through the existing syntax for aesthetic mappings. But i don't have the proficiency with {grid} to build such a package myself. Please let me know if you have any ideas and feel free to invite others to comment. I'd be glad to work with someone to make it happen.

corybrunson commented 2 months ago

@AliceL90 on looking back at {ggpattern} i came across {gridpattern}, which seems to be exactly what i thought did not exist—an extension of {grid} that provides these patterns as graphical objects (grobs). The patterns can be used directly through {ggplot2} without {ggpattern}, as demonstrated here. I haven't tried it with {ggalluvial}; please let me know if it satisfies your needs.

AliceL90 commented 2 months ago

Thanks a lot @corybrunson, it did work perfectly :)

corybrunson commented 2 months ago

Excellent! I'll open a new issue to illustrate use with {gridpattern} in a vignette.

AliceL90 commented 2 months ago

Great! Thank you