Image credit: Pexels and Scott Webb

# Extending ggplot2

There are numerous ways in which you can extend ggplot2 package. In this post, I am going to talk about 3 packages that are relevant to us immediately.

### Extrafont

The first package is extrafont, which enables importing font files from your computer to R. You will have to do this only once after you install the package and then in future whenever you want to use different fonts, you can simply call them by name in ggplot2. The limitation of this package is that currently it handles only TrueType fonts (ttf).

You can download the package from CRAN directly and install using install.packages('extrafont')

More information about extrafont is available here: https://cran.r-project.org/web/packages/extrafont/README.html

### Showtext

The second package is showtext which overcomes the limitation of extrafont and allows you to use other types (e.g., OpenType) fonts. I like showtext a lot. It’s a modern package and you will be better off using it because it doesn’t have to populate all the fonts on your system. However, this means that you will have to specifically load the fonts you want to use in your plot.

You can download the package from CRAN directly and install using install.packages('showtext')

More information about showtext from the package creator: https://cran.r-project.org/web/packages/extrafont/README.html

### Ggstatsplot

In data science we need to create several plots to explore relationships between variables. ggstatsplot makes this task easy.

You can download the package from CRAN directly and install using install.packages('ggstatsplot')

Check out the package documentation here: https://indrajeetpatil.github.io/ggstatsplot/