fig: Change repr.plot.* behaviour

View source: R/func_basics.R

figR Documentation

Change ⁠repr.plot.*⁠ behaviour

Description

Change the behaviour of ⁠repr.plot.*⁠.

Usage

fig(
  width = 10,
  height = 7,
  pointsize = 12,
  bg = "white",
  antialias = "gray",
  res = 120,
  quality = 90,
  family = "sans"
)

reset.fig(
  width = 10,
  height = 7,
  pointsize = 12,
  bg = "white",
  antialias = "gray",
  res = 120,
  quality = 90,
  family = "sans"
)

Arguments

width

Plotting area width in inches. Default is 10.

height

Plotting area height in inches. Default is 7.

pointsize

Text height in pt. Default is 12.

bg

Background colour. Default is "white".

antialias

Which kind of antialiasing to use for for lines and text? 'gray', 'subpixel' or 'none'? Default is "gray".

res

PPI for rasterization. Defaults to 120.

quality

Quality of JPEG format in %. Default is 90.

family

Font family. "sans", "serif", "mono" or a specific one. Default is "sans".

Details

The function uses options() to change the behaviour of ⁠repr.plot.*⁠. It provides a quick and easy way to change plot size and other ⁠repr.plot.*⁠ behaviours when running R in a Jupyter Notebook. If use without indicating any argument, the plot behaviour will be reset to default. The reset.fig() is an alias of fig().

Author(s)

I-Hsuan Lin

Examples

## Not run: 
library(ggplot2)

# Change plot area width to 8 inches and height to 5 inches
fig(width = 8, height = 5)
ggplot(mpg, aes(class)) +
  geom_bar()

# Reset to default settings
fig()

# Change plot wider and taller
fig(width = 14, height = 10)
ggplot(mpg, aes(class)) +
  geom_bar()

# Alias of fig()
reset.fig()

## End(Not run)

ycl6/scRUtils documentation built on Feb. 18, 2025, 6:14 a.m.