subt: [+] Add bold title and subtitle to a plot

View source: R/subt.R

subtR Documentation

[+] Add bold title and subtitle to a plot

Description

Add bold title with second line in smaller font with subtitle. Functions bquote and atop are used to achieve this effect.

Usage

subt(Title = NULL, subTitle = NULL)

Arguments

Title

The first line of title, which will be in bold.

subTitle

The second line of title, which will be smaller and and in italics.

Value

Formated title.

Warning!

May not work with plotting functions from package hyperSpec.

Author(s)

Vilmantas Gegzna

See Also

Other spHelper utilities: IQR_outliers(), expr2text(), mad_outliers(), rmExpr(), sd_outliers(), unGroup(), uncall()

Examples


subt("Cars")
## bold("Cars")

subt("Cars","Distance vs. speed")
## atop(bold("Cars"), atop(italic("Distance vs. speed")))

# ----------------------------------------------------------------

plot(cars[,1:2], main = "Cars")
plot(cars[,1:2], main = subt("Cars")) # the same as in previous line
plot(cars[,1:2], main = subt("Cars","Distance vs. speed"))
plot(cars[,1:2], main = subt(subTitle = "Distance vs. speed"))

# ----------------------------------------------------------------

library(ggplot2)

g <- qplot(mpg, wt, data=mtcars)
g + ggtitle("Cars") # non-bold title
g + ggtitle(subt("Cars")) # bold title
g + ggtitle(subt("Cars","Distance vs. speed"))
g + ggtitle(subt(subTitle = "Distance vs. speed"))


# ----------------------------------------------------------------

library(lattice)

xyplot(eruptions~waiting, data = faithful)

xyplot(eruptions~waiting, data = faithful,
 main = "Old Faithful Geyser Data")

xyplot(eruptions~waiting, data = faithful,
 main = subt("Old Faithful Geyser Data"))

xyplot(eruptions~waiting, data = faithful,
 main = subt("Old Faithful Geyser", "Data"))

xyplot(eruptions~waiting, data = faithful,
 main = subt(subTitle = "Old Faithful Geyser Data"))


GegznaV/spHelper documentation built on April 16, 2023, 1:42 p.m.