addGGFFLayer: Add FatFonts layers to a ggplot object

Description Usage Arguments Examples

Description

addGGFFLayer() adds FatFonts layers to an existing ggplot object. It can be used to build FatFonts plots other than confusion matrix, heatmap, correlation matrix and clustered scatter plot.

Usage

1
2
3
addGGFFLayer(oldPlot, data, xBinLength = 1, yBinLength = 1, font = 'Cubica',
fontSize = 3, fontColor = '#000000', adjustPos = 2, changeFontColValue = NULL,
changeFontColDigit = NULL, ...)

Arguments

oldPlot

A ggplot object to which the FatFonts layers will be added

data

A vector containing the data that needs to be represented by FatFonts. The vector must has the same length as the data in the original ggplot object does.

xBinLength

The difference between each two neighboring numbers on the x axis. (default: 1)

yBinLength

The difference between each two neighboring numbers on the y axis. (default: 1)

font

The FatFonts family used in the plot. There are currently three FatFonts types available: "Cubica", "Miguta" and "Rotunda". (default: 'Cubica')

fontSize

The font size of the smallest FatFonts digit. (default: 3)

fontColor

The font color of FatFonts digits. (default: '#000000')

adjustPos

Parameter used to slightly adjust the location of FatFonts digits. (default: 2)

changeFontColValue

A function used to change font color based on value. An example function can be defined as follow: changeFontColValueFunc <- function(oldPlot)newPlot <- oldPlot + scale_color_gradient2(); return(newPlot). (default: NULL)

changeFontColDigit

A vector containing the 9 colors used to represent each digit respectively (in the order of 1 to 9). You can also use color combinations provided by the system (e.g. topo.colors(9)). (default: NULL)

...

Other arguments passed on to methods. Not currently used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Library
library(ggplot2)
library(ggFatFonts)

# Creat test dataset
test <- data.frame(var1 = c('a', 'a', 'b', 'b'),
                   var2 = c('a', 'c', 'a', 'd'),
                   fill = c(12, 53, 87, 6))

# Create ggplot without FatFonts layer
myPlot <- ggplot(data = test, mapping = aes(x = var1, y = var2, fill = fill)) +
  geom_tile() +
  coord_fixed(ratio = 1, expand = FALSE)

# Add FatFonts layer
myPlot <- addGGFFLayer(oldPlot = myPlot,
                       data = test[, 3],
                       xBinLength = 1,
                       yBinLength = 1,
                       font = 'Cubica',
                       fontSize = 3,
                       fontColor = '#FFFFFF',
                       adjustPos = 7.5)

print(myPlot)

purpleleaf95/ggFatFonts documentation built on May 15, 2019, 1:18 p.m.