4 ms·
What is meant by "a grammar"? Is it the way we concatenate functions to create what's essentially a sentence of what we want the plot to be?
by Waterluvian 9y ago
What is meant by "a grammar"?
Is it the way we concatenate functions to create what's essentially a sentence of what we want the plot to be?
- vignesh_m 9y agoI found http://r-statistics.co/ggplot2-Tutorial-With-R.html http://r-statistics.co/ggplot2-Tutorial-With-R.html helpful to learn about the gglplot "grammar of graphs"
- perturbation 9y agoggplot2 was inspired by: https://www.amazon.com/Grammar-Graphics-Statistics-Computing/dp/0387245448 https://www.amazon.com/Grammar-Graphics-Statistics-Computing... and Hadley Wickham wrote about it in http://vita.had.co.nz/papers/layered-grammar.pdf http://vita.had.co.nz/papers/layered-grammar.pdf. I'm no expert, but I think that one of the main ideas is to separate the elements of making a plot from the way that the data is presented. For example, in ggplot2, you have the data that will go into the graph, the type of plot (or "geometry") that defines how the data are presented (scatterplot, bar plot, etc.), and then various "layers" that can be added that affect style. In order to split a plot into subplots, you simply define how it is to be faceted (what column should be used to define groups). Grammar-of-graphics moves plotting away from the "turtle graphics" model and lets you specify what should be done. Then ggplot figures out how to do it, kind of like SQL vs. writing for loops to retrieve information.
- Waterluvian 9y agoAha! Thank you. So it's kind of like a declarative way of plotting.