diff --git a/NAMESPACE b/NAMESPACE index 6d27aabb..5efb2d79 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -151,6 +151,7 @@ export(useDarkTheme) export(useExcelTheme) export(useHighChartTheme) export(useMatlabTheme) +export(useMinimalTheme) export(useTemplateTheme) export(useTheme) import(ggplot2) diff --git a/R/utilities-theme.R b/R/utilities-theme.R index 12082fd1..f5ecd7f4 100644 --- a/R/utilities-theme.R +++ b/R/utilities-theme.R @@ -186,6 +186,17 @@ useHighChartTheme <- function() { useTheme(loadThemeFromJson(system.file("themes", "hc-theme.json", package = "tlf"))) } +#' @title useMinimalTheme +#' @description +#' Set default minimal theme to be used as the current default of the tlf environment +#' @export +#' @examples +#' useMinimalTheme() +#' addScatter(x = seq(1,10), y = rnorm(10)) +useMinimalTheme <- function() { + useTheme(loadThemeFromJson(system.file("themes", "minimal-theme.json", package = "tlf"))) +} + ## ------------------------------------------------- #' @title runThemeMaker #' @description diff --git a/R/utils.R b/R/utils.R index fb960e8e..bca55518 100644 --- a/R/utils.R +++ b/R/utils.R @@ -41,3 +41,5 @@ ifIncluded <- function(x, y, outputIfIncluded, outputIfNotIncluded = NULL) { # Because collate put tlf-env and themes before utils, # The curretnTheme is defined here: after the definition of %||% tlfEnv$currentTheme <- Theme$new() +# Default theme is minimal when package is loaded +useMinimalTheme() \ No newline at end of file diff --git a/inst/themes/minimal-theme.json b/inst/themes/minimal-theme.json new file mode 100644 index 00000000..1a3f1395 --- /dev/null +++ b/inst/themes/minimal-theme.json @@ -0,0 +1,358 @@ +{ + "fonts": { + "title": { + "color": "grey20", + "size": 12, + "fontFace": "plain", + "fontFamily": "", + "angle": 0 + }, + "subtitle": { + "color": "grey20", + "size": 10, + "fontFace": "plain", + "fontFamily": "", + "angle": 0 + }, + "xlabel": { + "color": "grey20", + "size": 10, + "fontFace": "plain", + "fontFamily": "", + "angle": 0 + }, + "ylabel": { + "color": "grey20", + "size": 10, + "fontFace": "plain", + "fontFamily": "", + "angle": 90 + }, + "watermark": { + "color": "grey20", + "size": 12, + "fontFace": "plain", + "fontFamily": "", + "angle": 30 + }, + "legend": { + "color": "grey20", + "size": 10, + "fontFace": "plain", + "fontFamily": "", + "angle": 0 + }, + "xAxis": { + "color": "grey20", + "size": 10, + "fontFace": "plain", + "fontFamily": "", + "angle": 0 + }, + "yAxis": { + "color": "grey20", + "size": 10, + "fontFace": "plain", + "fontFamily": "", + "angle": 0 + } + }, + "background": { + "watermark": "", + "legendPosition": "insideTopRight", + "plot": { + "fill": "white", + "color": "grey20", + "size": 0.5, + "linetype": "blank" + }, + "panel": { + "fill": "white", + "color": "grey20", + "size": "0.5", + "linetype": "blank" + }, + "xAxis": { + "color": "grey20", + "size": "0.5", + "linetype": "solid" + }, + "yAxis": { + "color": "grey20", + "size": "0.5", + "linetype": "solid" + }, + "xGrid": { + "color": "grey20", + "size": "0.5", + "linetype": "blank" + }, + "yGrid": { + "color": "grey20", + "size": "0.5", + "linetype": "blank" + }, + "legend": { + "fill": "white", + "color": "white", + "size": "0.5", + "linetype": "blank" + } + }, + "aestheticMaps": { + "color": [ + "#0078D7", + "#D83B01", + "#107C10", + "#A80000", + "#002050", + "#B4009E" + ], + "fill": [ + "#0078D7", + "#D83B01", + "#107C10", + "#A80000", + "#002050", + "#B4009E" + ], + "shape": [ + "square", + "dot", + "circle", + "diamond", + "star", + "plus", + "cross", + "triangle" + ], + "linetype": [ + "solid", + "longdash", + "dotted", + "dashed", + "twodash", + "dotdash" + ], + "size": [ + 1, + 2, + 3, + 4, + 5 + ], + "alpha": [ + 0.75, + 0.5, + 0.25 + ] + }, + "plotConfigurations": { + "addScatter": { + "color": "next", + "fill": "NA", + "shape": "next", + "linetype": "blank", + "size": "first", + "alpha": 1 + }, + "addLine": { + "color": "next", + "fill": "NA", + "shape": "blank", + "linetype": "same", + "size": "first", + "alpha": 1 + }, + "addRibbon": { + "color": "next", + "fill": "next", + "shape": "blank", + "linetype": "same", + "size": "first", + "alpha": "first" + }, + "addErrorbar": { + "color": "next", + "fill": "NA", + "shape": "blank", + "linetype": "first", + "size": "first", + "alpha": 1 + }, + "plotPKRatio": { + "points": { + "color": "reset", + "fill": "NA", + "shape": "reset", + "linetype": "blank", + "size": 2, + "alpha": 1 + }, + "lines": { + "color": "grey20", + "fill": "NA", + "shape": "blank", + "linetype": "longdash", + "size": 0.5, + "alpha": 1 + }, + "errorbars": { + "color": "reset", + "fill": "NA", + "shape": "blank", + "linetype": "solid", + "size": 0.5, + "alpha": 1 + } + }, + "plotDDIRatio": { + "points": { + "color": "reset", + "fill": "NA", + "shape": "reset", + "linetype": "blank", + "size": 2, + "alpha": 1 + }, + "lines": { + "color": "grey20", + "fill": "NA", + "shape": "blank", + "linetype": "longdash", + "size": 0.5, + "alpha": 1 + }, + "errorbars": { + "color": "reset", + "fill": "NA", + "shape": "blank", + "linetype": "solid", + "size": 1, + "alpha": 1 + } + }, + "plotTimeProfile": { + "points": { + "color": "reset", + "fill": "NA", + "shape": "reset", + "linetype": "blank", + "size": 2, + "alpha": 1 + }, + "lines": { + "color": "reset", + "fill": "NA", + "shape": "blank", + "linetype": "reset", + "size": 0.5, + "alpha": 1 + }, + "ribbons": { + "color": "reset", + "fill": "reset", + "shape": "blank", + "linetype": "blank", + "size": 0.5, + "alpha": "first" + }, + "errorbars": { + "color": "reset", + "fill": "NA", + "shape": "blank", + "linetype": "solid", + "size": 0.5, + "alpha": 1 + } + }, + "plotObsVsPred": { + "points": { + "color": "reset", + "fill": "NA", + "shape": "reset", + "linetype": "blank", + "size": 2, + "alpha": 1 + }, + "lines": { + "color": "grey20", + "fill": "NA", + "shape": "blank", + "linetype": "longdash", + "size": 0.5, + "alpha": 1 + }, + "errorbars": { + "color": "reset", + "fill": "NA", + "shape": "blank", + "linetype": "solid", + "size": 0.5, + "alpha": 1 + } + }, + "plotBoxWhisker": { + "points": { + "color": "grey20", + "fill": "NA", + "shape": "dot", + "linetype": "blank", + "size": 2, + "alpha": 1 + }, + "ribbons": { + "color": "grey20", + "fill": "reset", + "shape": "blank", + "linetype": "solid", + "size": 0.5, + "alpha": "first" + } + }, + "plotTornado": { + "lines": { + "color": "grey20", + "fill": "NA", + "shape": "blank", + "linetype": "longdash", + "size": 0.5, + "alpha": 1 + }, + "points": { + "color": "reset", + "fill": "NA", + "shape": "reset", + "linetype": "blank", + "size": 2, + "alpha": 1 + }, + "ribbons": { + "color": "reset", + "fill": "reset", + "shape": "blank", + "linetype": "solid", + "size": 0.5, + "alpha": "first" + } + }, + "plotHistogram": { + "lines": { + "color": "next", + "fill": "NA", + "shape": "blank", + "linetype": "solid", + "size": 0.5, + "alpha": 1 + }, + "ribbons": { + "color": "grey20", + "fill": "reset", + "shape": "blank", + "linetype": "solid", + "size": 0.5, + "alpha": "first" + } + } + } +} \ No newline at end of file diff --git a/man/useMinimalTheme.Rd b/man/useMinimalTheme.Rd new file mode 100644 index 00000000..959e1805 --- /dev/null +++ b/man/useMinimalTheme.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utilities-theme.R +\name{useMinimalTheme} +\alias{useMinimalTheme} +\title{useMinimalTheme} +\usage{ +useMinimalTheme() +} +\description{ +Set default minimal theme to be used as the current default of the tlf environment +} +\examples{ +useMinimalTheme() +addScatter(x = seq(1,10), y = rnorm(10)) +} diff --git a/vignettes/atom-plots.Rmd b/vignettes/atom-plots.Rmd index 8467a83f..39a78815 100644 --- a/vignettes/atom-plots.Rmd +++ b/vignettes/atom-plots.Rmd @@ -24,10 +24,7 @@ knitr::opts_chunk$set( require(tlf) ``` -```{r load-theme, echo=FALSE} -vignetteTheme <- loadThemeFromJson(system.file("extdata", "template-theme.json", package = "tlf")) -useTheme(vignetteTheme) - +```{r load-data, echo=FALSE} cosData <- data.frame(time = seq(0, 20, 0.5), cos = cos(seq(0, 20, 0.5)), sin = sin(seq(0, 20, 0.5))) testData <- read.csv(system.file("extdata", "test-data.csv", package = "tlf"), stringsAsFactors = FALSE) ``` diff --git a/vignettes/box-whisker-vignette.Rmd b/vignettes/box-whisker-vignette.Rmd index caee60e9..0196b4e8 100644 --- a/vignettes/box-whisker-vignette.Rmd +++ b/vignettes/box-whisker-vignette.Rmd @@ -26,11 +26,6 @@ knitr::opts_chunk$set( require(tlf) ``` -```{r load-theme, echo=FALSE} -vignetteTheme <- loadThemeFromJson(system.file("extdata", "template-theme.json", package = "tlf")) -useTheme(vignetteTheme) -``` - # 1. Introduction The following vignette aims at documenting and illustrating workflows for producing box-and-whisker plots using the `tlf`-Library. diff --git a/vignettes/histogram.Rmd b/vignettes/histogram.Rmd index eedddebc..9058aca9 100644 --- a/vignettes/histogram.Rmd +++ b/vignettes/histogram.Rmd @@ -25,11 +25,6 @@ knitr::opts_chunk$set( require(tlf) ``` -```{r load-theme, echo=FALSE} -vignetteTheme <- loadThemeFromJson(system.file("extdata", "template-theme.json", package = "tlf")) -useTheme(vignetteTheme) -``` - # 1. Introduction The following vignette aims at documenting and illustrating workflows for producing histograms using the function `plotHistogram` from the `tlf` package. diff --git a/vignettes/pk-ratio-vignette.Rmd b/vignettes/pk-ratio-vignette.Rmd index 8ac9ff14..c35bcde6 100644 --- a/vignettes/pk-ratio-vignette.Rmd +++ b/vignettes/pk-ratio-vignette.Rmd @@ -24,11 +24,6 @@ knitr::opts_chunk$set( require(tlf) ``` -```{r load-theme, echo=FALSE} -vignetteTheme <- loadThemeFromJson(system.file("extdata", "template-theme.json", package = "tlf")) -useTheme(vignetteTheme) -``` - # 1. Introduction The following vignette aims at documenting and illustrating workflows for producing PK ratio plots using the `tlf`-Library. diff --git a/vignettes/plot-configuration.Rmd b/vignettes/plot-configuration.Rmd index ba9759d9..8ad9c922 100644 --- a/vignettes/plot-configuration.Rmd +++ b/vignettes/plot-configuration.Rmd @@ -24,11 +24,6 @@ knitr::opts_chunk$set( require(tlf) ``` -```{r load-theme, echo=FALSE} -vignetteTheme <- loadThemeFromJson(system.file("extdata", "template-theme.json", package = "tlf")) -useTheme(vignetteTheme) -``` - This vignette tackles about *PlotConfiguration* objects and their implementation within the `tlf`-library. # 1. Introduction diff --git a/vignettes/plot-time-profile.Rmd b/vignettes/plot-time-profile.Rmd index 9559144a..65f6a9cc 100644 --- a/vignettes/plot-time-profile.Rmd +++ b/vignettes/plot-time-profile.Rmd @@ -22,11 +22,7 @@ knitr::opts_chunk$set( ```{r setup} require(tlf) -``` - -```{r load-theme, echo=FALSE} -vignetteTheme <- loadThemeFromJson(system.file("extdata", "template-theme.json", package = "tlf")) -useTheme(vignetteTheme) +# Place default legend position above the plot for prettier time profile plots setDefaultLegendPosition(LegendPositions$outsideTop) ``` diff --git a/vignettes/tlf.Rmd b/vignettes/tlf.Rmd index 1e433e78..c7afcfd2 100644 --- a/vignettes/tlf.Rmd +++ b/vignettes/tlf.Rmd @@ -24,11 +24,6 @@ knitr::opts_chunk$set( require(tlf) ``` -```{r load-theme, echo=FALSE} -vignetteTheme <- loadThemeFromJson(system.file("themes", "template-theme.json", package = "tlf")) -useTheme(vignetteTheme) -``` - # 1. Introduction ## 1.1. Objectives