larmarange / ggstats

Extension to ggplot2 for plotting stats
https://larmarange.github.io/ggstats/
GNU General Public License v3.0
26 stars 1 forks source link

Feature request or workaround: Extending `gglikert` with `ggiraph`? #46

Closed sda030 closed 10 months ago

sda030 commented 10 months ago

Dear @larmarange, your gglikert and gglikert_stacked are exactly the ready-made solutions for what I have been to a large extent implementing manually. However, I would also need some ggiraph interactivity added. Would you happen to know of a way for me to use ggstats as the foundation, and then add ggiraph on top? This is for a new package in development so if there is some dirty hack that I could hide within a wrapper function, it would be ok. Though I guess it would require replacing many of the ggplot2 geoms, scales, etc with the corresponding ones from ggiraph. The specific part that I need is that hovering over a category (a cell) highlights the count. Perhaps also more info such as showing the variable name when clicking on the variable label, etc.

I expect you not wanting to pull in another dependency such as ggiraph. Would however a conditional check of whether ggiraph is installed, and a new default argument interactive = FALSE be something to consider, if the wrapper approach seems tricky?

Best

larmarange commented 10 months ago

If you need interactivity, why not using Plotly? you can pass directly the result of gglikert() to plotly::ggplotly() to get an interactive graph.

larmarange commented 10 months ago

Note: you can use gglikert_data() to process the data and get a tibble ready to be used with your own graph, using geom_bar() with stat_likert().

I do not know if geom_bar_interactive() is compatible with other stat functions

sda030 commented 10 months ago

If you need interactivity, why not using Plotly? you can pass directly the result of gglikert() to plotly::ggplotly() to get an interactive graph.

I found Plotly quick and neat, but ggplotly a bit limited in specifying the onClick, hover, etc attributes. I could not figure out how to explicitly configure a count variable to be displayed on hover. Also, Plotly is perhaps not as pretty as ggplot/ggiraph/ggstats, but that is my opinion.

Note: you can use gglikert_data() to process the data and get a tibble ready to be used with your own graph, using geom_bar() with stat_likert().

stat_likert()? Where do I find this?

P.S. Going on holiday soon so I will likely not be able to try this out for a couple of weeks.

larmarange commented 10 months ago

Sorry. I meant position_likert()

https://larmarange.github.io/ggstats/reference/position_likert.html