Sunflower Plot Using ggplot2

I am interested in creating a sunflower plot using ggplot2. In a sunflower plot, overplotted points are visualized as "sunflowers," with each "leaf" representing the number of data points at that location. While I am familiar with the sunflowerplot() function in the graphics package, I am exploring ggplot2 for its seamless integration with other geom layers. Here is a base graphics example:

tb <- tibble(
  x = c(rep(0, 5), rep(1, 1), rep(0, 3), rep(1, 2)),
  y = c(rep(0, 5), rep(1, 1), rep(1, 3), rep(0, 2))
)
sunflowerplot(tb$x, tb$y)

I am specifically seeking a ggplot2 solution that mirrors the functionality of geom_count(), but uses the number of "petals" rather than point size to represent counts. While I am aware of alternatives like geom_jitter() or geom_beeswarm() for mitigating overplotting, my focus remains on crafting a sunflower plot.

Despite scouring the web, I have yet to discover a suitable ggplot2 add-on package or workaround. The term "sunflower plot" surfaced in a thread titled Plotting a Scatter Plot with Categorical Data within the Posit community. However, this discussion lacked accompanying code, and the featured plot was not a sunflower plot.

If anyone has encountered a ggplot2-based sunflower plot solution or has a clever hack to achieve this visualization, I would greatly appreciate your insights.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.