Extract data from ggplot plot
✓ Published0🌍 Public
LLuisSevillano
Last edited Sep 30, 2019
Created on Sep 30, 2019
The example demonstrates how to extract the underlying point positions from a ggplot2 scatter plot after applying jittering, then re-plot those extracted coordinates with higher transparency to reveal overplotting patterns. Built with R’s ggplot2, the initial plot uses `geom_point` with `position_jitter(h = 0)` and an alpha of 1/100, producing a dense darkred cloud of age versus dependent variable. The code then calls `layer_data(plot, 1)` to retrieve the jittered x and y values from the first layer, feeding them into a new ggplot with `geom_point(alpha = 1/20)`, increasing visibility of individual points that were previously obscured by the heavy overdraw.
AI-generated description