Skip to content

Instantly share code, notes, and snippets.

@baptiste
Created September 25, 2016 09:00
Show Gist options
  • Save baptiste/3ce764ef0cac5a9910cec103fefc832a to your computer and use it in GitHub Desktop.
Save baptiste/3ce764ef0cac5a9910cec103fefc832a to your computer and use it in GitHub Desktop.
d <- data.frame(x=1:20, f = gl(2, 10))
p <- ggplot(d, aes(x,x, colour=x)) + facet_grid(.~f) +
ggtitle("facetted plot")
library(egg)
expose_layout(p)
@baptiste
Copy link
Author

baptiste commented Sep 25, 2016

just thinking out loud really – i've had this idea for a while that a better way to define plot layouts (and by extension other display characteristics) would be to have a dummy template that can be interacted with via direct manipulation. A dummy plot, not showing actual data, but just the skeleton of all object elements a bit like this,

screen shot 2016-09-25 at 10 00 15 pm

The next step is to have an interactive way of manipulating this template. Ideally some kind of vector graphics editor such as svg-edit, but perhaps more easily a Shiny app with sliders and buttons instead. It makes it easier to adjust various numerical values and keep constraints between different elements. For instance, one could select the font type, font size, justification of all element_text appearing in a theme. The plot margins would be set with a slider. The colours would be selected from a palette, potentially helping with matching colour schemes for the various background/foreground elements.

In fact, the whole thing brings back memories of a similar idea that I suggested years ago to visualise geom default settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment