zazizoma
zazizoma

Reputation: 567

autoload ggplot2 custom theme

I'm using R and Jupyter and would like a custom theme to be loaded automatically upon startup. I've defined a custom theme function, and when I define it within a session it works as expected. I've tried putting the definition in my local .Rprofile, but when I restart an R kernel the theme is no longer available. How do I make these themes persist across sessions?

For example, the theme_nothing is defined via

theme_nothing <- function(base_size = 12, base_family = "Helvetica")
{
theme_bw(base_size = base_size, base_family = base_family) %+replace%
  theme(
        rect             = element_blank(),
        line             = element_blank(),
        text             = element_blank()
       )
}e 

in a cell, and when that cell is executed I can use this theme. But if I close the session, I need to redefine the theme in order to use it. I want it to load automatically with any new R kernel.

(I've read the theme vignette but didn't find anything on persistance.)

Upvotes: 0

Views: 607

Answers (1)

user7396508
user7396508

Reputation:

Insert theme_set at the start of your script

theme_set(theme_nothing())

To do this you will also have to include a path to the location the theme is stored first eg,

source('~where/the/file/is.R)

Upvotes: 1

Related Questions