-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental graphs in ggplot2 #24
Comments
Sounds cool! Have you thought about how to implement it? |
Yeah, this sounds awesome! Such a natural consequence of In fact, library(ggplot2)
pl <- ggplot(mtcars) +
geom_line(aes(x = wt, y = mpg)) +
ggtitle("mpg vs wt") +
geom_point(aes(x = wt, y = mpg, color = as.factor(cyl))) +
ggtitle("mpg vs wt with line")
pl pl$layers
#> [[1]]
#> mapping: x = ~wt, y = ~mpg
#> geom_line: na.rm = FALSE
#> stat_identity: na.rm = FALSE
#> position_identity
#>
#> [[2]]
#> mapping: x = ~wt, y = ~mpg, colour = ~as.factor(cyl)
#> geom_point: na.rm = FALSE
#> stat_identity: na.rm = FALSE
#> position_identity
# Remove a layer.
pl$layers <- pl$layers[-1]
pl Created on 2019-03-07 by the reprex package (v0.2.1) But that's not what we want because both frames have "with line" in the title. Hence, @maurolepore's idea of computing on the language. A couple more ideas:
pl <- ggplot(mtcars) +
geom_line(aes(x = wt, y = mpg)) +
ggtitle("mpg vs wt") +
increment() +
geom_point(aes(x = wt, y = mpg, color = as.factor(cyl))) +
ggtitle("mpg vs wt with line") +
increment() |
I am a fan of showing graphs layer by layer in slideshows. I find that my workflow ends up being something like
This ends up involving a lot of copying and pasting. It's not the worst thing since ggplot syntax fits well with the layering idea, but I have found it to be enough work that I don't always do it. I've thought it would be nice to have some functions that can take a plot and show you just the parts you want. Roughly,
The text was updated successfully, but these errors were encountered: