Yes, you can use ggplot2::theme_set() to set the default theme. To set default color palettes I think the best way to do it is to redefine the default scale functions to use the defaults you want.
If you want to have your internal package automatically set the default color scales and theme you can do so by setting them in .onAttach. This will change the defaults automatically anytime your package is attached with library(), so the results will be reproducible in the future. This code assumes ggplot2 is in your internal packages Depends, and you need to assign the scales in the global (rather than package) environment.
.onAttach <- function(pkgname, libname) {
my_palette <- c('blue', 'black', 'red')
my_theme <- theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5))
theme_set(my_theme)
assign("scale_colour_discrete", function(..., values = my_palette) scale_colour_manual(..., values = values), globalenv())
assign("scale_fill_discrete", function(..., values = my_palette) scale_fill_manual(..., values = values), globalenv())
}
With this done you the results will be automatically used after you attach your internal package.
library(myinternalpkg)
#> Loading required package: ggplot2
ggplot(iris) +
geom_point(aes(x = Sepal.Length, y = Sepal.Width, color = Species))
