---
title: "ggstatsplot theme"
author: "Indrajeet Patil"
date: "`r Sys.Date()`"
output:
  rmarkdown::html_vignette:
    fig_width: 6
    fig.align: 'center'
    fig.asp: 0.618
    dpi: 300
    warning: FALSE
    message: FALSE
vignette: >
  %\VignetteIndexEntry{ggstatsplot theme}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  dpi = 300,
  out.width = "100%",
  collapse = TRUE,
  comment = "#>"
)
```

## Default theme for the package: `theme_ggstatsplot`

`ggstatsplot` uses a default theme `theme_ggstatsplot()`, which is a selected `ggplot2`
theme with few aesthetic modifications overlaid on top, that can be used with any
`ggplot2` object. Alternative name for this function is `theme_mprl`.

Here is a simple example:

```{r theme_ggstatsplot, message = FALSE, warning = FALSE, fig.height = 4, fig.width = 4}
library(ggplot2)

# Basic scatter plot
ggplot2::ggplot(
  data = datasets::mtcars, 
  mapping = ggplot2::aes(x = wt, y = mpg)
) + 
  ggplot2::geom_point() +
  ggplot2::theme_bw()

# Basic scatter plot with theme_ggstatsplot() added
ggplot2::ggplot(
  data = datasets::mtcars, 
  mapping = ggplot2::aes(x = wt, y = mpg)
) + 
  ggplot2::geom_point() + 
  ggstatsplot::theme_ggstatsplot(ggtheme = ggplot2::theme_bw())
```

All plots in this package have `theme_bw()` by default as the base on which
`theme_ggstatsplot()` is built, but this can be modified using the `ggtheme` argument
provided for all functions. For example, for the `ggbetweenstats` function the
default theme can be changed to, for example, `theme_grey()`:

```{r theme1, message = FALSE, warning = FALSE, fig.height = 6, fig.width = 8}
ggstatsplot::ggbetweenstats(
  data = datasets::iris,
  x = Species,
  y = Sepal.Length,
  ggtheme = ggplot2::theme_grey()          # selected ggplot2 theme
)
```

Another example with `ggscatterstats`:
```{r theme2, message = FALSE, warning = FALSE, fig.height = 6, fig.width = 8}
ggstatsplot::ggscatterstats(
  data = datasets::iris,
  x = Sepal.Width,
  y = Sepal.Length,
  ggtheme = ggplot2::theme_dark()          # selected ggplot2 theme
)
```

The only exception for how `ggtheme` argument is to be entered is `ggcorrmat`
function where the theme should **not** be entered as a function.
```{r theme3, message = FALSE, warning = FALSE, fig.height = 6, fig.width = 6}
ggstatsplot::ggcorrmat(
  data = datasets::iris,
  cor.vars = c(Sepal.Length:Petal.Width),
  type = "upper",
  ggtheme = ggplot2::theme_dark            # selected ggplot2 theme
)
```


## Suggestions

If you find any bugs or have any suggestions/remarks, please file an issue on
GitHub: <https://github.com/IndrajeetPatil/ggstatsplot/issues>
