These functions provide a robust way to find grob elements and generate CSS selectors, independent of panel structure or hardcoded values. Find grob by element type pattern
find_graphics_plot_grob(grob, element_type, plot_index = NULL)The name of the first matching grob, or NULL if not found
The grob tree to search (typically from ggplotify::as.grob())
The element type to search for (e.g., "rect", "lines", "points")
Optional plot index to match (for multipanel layouts)
Searches recursively through a grob tree to find a grob whose name matches the pattern: graphics-plot-<number>-<element_type>-<number>