ggplot2 has become the standard of plotting in R for many users. New users, however, may find the learning curve steep at first, and more experienced users may find it challenging to keep track of all the options (especially in the theme!).
ggedit is a package that helps users bridge the gap between making a plot and getting all of those pesky plot aesthetics just right, all while keeping everything portable for further research and collaboration.
ggedit is powered by a Shiny gadget where the user inputs a ggplot plot object or a list of ggplot objects. You can run ggedit directly from the console or from the Addin menu within RStudio.
A gitbook is maintained as the user manual for the package, you can access it here:
https://metrumresearchgroup.github.io/ggedit/
Short clip from rstudio::conf 2017 (13:40-19:40)
User Lightning Talks โ RStudio
install.packages('ggedit')
For a quick example, run the following:
library('ggedit')
library(ggplot2)
p <- ggplot(mtcars, aes(x = hp, y = wt)) + geom_point() + geom_smooth()
p2 <- ggedit(p)
names(p2) # will show you which objects are available.
plot(p2) # shows the updated plot (it is available in the first element of p2)
devtools::install_github("metrumresearchgroup/ggedit")
DEV updates ggedit_0.2.2
-
replaced
mutate_each
withmutate_all
to be compatible with newdplyr
release -
functionality added
- can pass functions into stat_summary, eg
stat_summary(fun.y=mean_sd, geom='point')
- data.frames in layers are embedded as structures in verbose outputs, e.g.
geom_point(data=mtcars, aes(cyl, mpg))
will return
[1] "geom_point(mapping=aes(x=cyl,y=mpg), data=structure(list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1, 14.3, \n24.4, 22.8, 19.2, 17.8, 16.4, 17.3, 15.2, 10.4, 10.4, 14.7, 32.4,.. <truncated>
- aesthetic can be set to NULL, ie aes(group=NULL)
- can pass functions into stat_summary, eg
example plot
plot <-
iris%>%
ggplot(aes(x=cut(Sepal.Width,2),y=Sepal.Width)) +
aes(colour=Species,group=Species)+
geom_point(alpha = 0.5,shape = 16, size = 1) +
geom_boxplot(aes(group=NULL), varwidth = FALSE,notch = FALSE, show.legend = TRUE)+
stat_summary(fun.y = 'median', geom = "line")+
theme_bw(base_size = 16) +
theme(legend.position = "bottom",
legend.box = "vertical", legend.direction = "horizontal",
axis.text.x = ggplot2::element_text(angle = 90,hjust = 1, vjust = 0.5),
legend.title = element_blank())
ggedit(plot)
- layers
- non colour aesthetics of numeric inputs are not currently supported, e.g.:
iris%>%ggplot(aes(x=Sepal.Length,y=Sepal.Width))+geom_point()+geom_text(aes(label=Species,size=Sepal.Length))
- geom_text: family is not currently open to change
- non colour aesthetics of numeric inputs are not currently supported, e.g.:
- theme
- margin,arrow are not currently available to edit