This package helps you build FatFonts graphics based on ggplot2.
FatFonts is a visualization technique which can show the symbolic as well as the quantitative aspects of numbers simultaneously, in a way that both overview and detailed views are supported. The order of each digit (i.e. in the unit¡¯s/ten¡¯s/hundred¡¯s place within a number) is revealed by the size of the whole area where the value of this digit can be represented, while the ink that is used to draw this digit in the area is determined by its exact value. There are three FatFonts types available: "Cubica", "Miguta" and "Rotunda".
The numbers in each plot represent 19, 28, 37, 46, 55, 64, 73, 82, 91 successively.
There are currently four quick plot functions provided: ggFFConfMatr
, ggFFHeatMap
, ggFFCorrMatr
and ggFFClusScatPlot
. They help to draw FatFonts Confusion Matrix, Heatmap, Correlation Matrix and Cluster Scatter Plot respectively. If you want to build some other plots using FatFonts, you can use addGGFFLayer
function.
This package only works on Windows OS for now.
library(ggFatFonts)
ggFFConfMatr(confMatrTestData$`actual value`, confMatrTestData$`predicted value`)
library(ggFatFonts)
library(ggplot2)
cols <- topo.colors(9)
ggFFHeatMap(x = txhousing$year[1:2000], y = txhousing$city[1:2000], z = txhousing$sales[1:2000], xAxisTitle = 'year', yAxisTitle = 'city', zAxisTitle = 'sales', fontSize = 2, changeFontColDigit = cols)
library(ggFatFonts)
library(ggplot2)
changeFontColValueFunc <- function(oldPlot){
newPlot <- oldPlot + scale_color_gradient2()
return(newPlot)
}
ggFFCorrMatr(mtcars[c(1, 3:7)], changeFontColValue = changeFontColValueFunc, adjustPos = 1, fontSize = 1)
library(ggFatFonts)
library(ggplot2)
changeBackColFunc <- function(oldPlot){
newPlot <- oldPlot + scale_fill_gradient(low = 'white', high = 'purple')
return(newPlot)
}
ggFFClusScatPlot(mpg$cty, mpg$hwy, xAxisTitle = 'cty', yAxisTitle = 'hwy', changeBackCol = changeBackColFunc, fontSize = 1.6)
A tutorial is provided to get you started. However, there are several things you need to do before running the tutorial. Please follow the instructions below.
Download the font files Cubica.otf, Miguta.otf and Rotunda.otf from the fonts subdirectory and then install them.
Run the following codes in R to install learnr
, devtools
, ggplot2
and ggFatFonts
if you haven't installed them before:
install.packages("learnr")
install.packages("devtools")
install.packages("ggplot2")
devtools::install_github("purpleleaf95/ggFatFonts")
If you are running the tutorial for the first time on your machine, the tutorial files need to be re-rendered. Please follow the instructions below:
C:\Program Files\R\R-3.x.x\library
. (Replace 3.x.x with the R version you are currently using) If you cannot find the path, open RStudio and click Tools -> Global Options... -> General. You will find the path in the R version block.\ggFatFonts\tutorials\tutorial
to the end of your local path (i.e. C:\Program Files\R\R-3.x.x\library\ggFatFonts\tutorials\tutorial
if you installed R using default settings). Find the tutorial.Rmd file and open it in RStudio.Run Document
.
Next time you want to open the tutorial, simply run the following code:
learnr::run_tutorial(name = 'tutorial', package = 'ggFatFonts')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.