Learn R Programming

sjPlot (version 1.7)

sjp.setTheme: Set global theme options for sjp-functions

Description

Set global theme options for sjp-functions.

Usage

sjp.setTheme(title.color = "black", title.size = 1.3,
  title.align = "left", geom.outline.color = NULL,
  geom.outline.size = 0.1, geom.boxoutline.size = 0.5,
  geom.boxoutline.color = "black", geom.alpha = 1, geom.linetype = 1,
  geom.errorbar.size = 0.7, geom.errorbar.linetype = 1,
  geom.label.color = NULL, geom.label.size = 4.5, geom.label.alpha = 1,
  geom.label.angle = 0, axis.title.color = "grey30",
  axis.title.size = 1.2, axis.angle.x = 0, axis.angle.y = 0,
  axis.angle = NULL, axis.textcolor.x = "grey30",
  axis.textcolor.y = "grey30", axis.textcolor = NULL,
  axis.linecolor.x = NULL, axis.linecolor.y = NULL, axis.linecolor = NULL,
  axis.line.size = 0.5, axis.textsize.x = 1.1, axis.textsize.y = 1.1,
  axis.textsize = NULL, axis.tickslen = NULL, axis.ticksol = NULL,
  axis.ticksmar = NULL, panel.backcol = NULL, panel.bordercol = NULL,
  panel.col = NULL, panel.major.gridcol = NULL,
  panel.minor.gridcol = NULL, panel.gridcol = NULL, plot.backcol = NULL,
  plot.bordercol = NULL, plot.col = NULL, legend.pos = "right",
  legend.just = NULL, legend.inside = FALSE, legend.size = 1,
  legend.color = "black", legend.title.size = 1,
  legend.title.color = "black", legend.title.face = "bold",
  legend.backgroundcol = "white", legend.bordercol = "white",
  theme = NULL, base = theme_grey())

Arguments

Value

The customized theme object, or NULL, if a ggplot-theme was used.

References

  • http://zevross.com/blog/2014/08/04/beautiful-plotting-in-r-a-ggplot2-cheatsheet-3/{Beautiful plotting in R: A ggplot2 cheatsheet}
  • http://minimaxir.com/2015/02/ggplot-tutorial/{An Introduction on How to Make Beautiful Charts With R and ggplot2}

See Also

  • http://www.strengejacke.de/sjPlot/custplot/{sjPlot manual: customize plot appearance}

Examples

Run this code
data(efc)
# set sjPlot-defaults, a slightly modification
# of the ggplot base theme
sjp.setTheme()

# legends of all plots inside
sjp.setTheme(legend.pos = "top left",
             legend.inside = TRUE)
sjp.xtab(efc$e42dep,
         efc$e16sex,
         showTableSummary = FALSE)

# Use classic-theme as base. you may need to
# load the ggplot2-library.
library(ggplot2)
sjp.setTheme(base = theme_classic())
sjp.frq(efc$e42dep)

# adjust value labels
sjp.setTheme(geom.label.size = 3.5,
             geom.label.color = "#3366cc",
             geom.label.angle = 90)
# hjust-aes needs adjustment for this
update_geom_defaults('text', list(hjust = -0.1))
sjp.xtab(efc$e42dep,
         efc$e16sex,
         showTableSummary = FALSE,
         labelPos = "center")

# Create own theme based on classic-theme
sjp.setTheme(base = theme_classic(),
             axis.linecolor = "grey50",
             axis.textcolor = "#6699cc")
sjp.frq(efc$e42dep)

# use theme pre-set, taken from tutorial
# http://minimaxir.com/2015/02/ggplot-tutorial/
sjp.setTheme(theme = "538",
             geom.alpha = 0.8)
library(ggplot2) # for custom base-line
sjp.frq(efc$e42dep,
        geom.color = "#c0392b",
        expand.grid = TRUE,
        printPlot = FALSE)$plot +
  geom_hline(yintercept = 0,
             size = 0.5,
             colour = "black")

Run the code above in your browser using DataLab