R365: Day 17 – Extra Fonts

I am not sure that I understand why people hate Comic sans so much, but in case you DON’T! you can easily make graphs using all sorts of fonts. The {extrafont} package holds lots of different fonts, from things you would find on most computers (Arial) to things that were designed seemingly for the purpose of programming languages (Humor sans, which mimics XKCD!). The computer standard ones are called TrueType, which were the standards for Apple and Microsoft. These include things like Helvetica, Times Roman, and Courier.

To install most of the TrueType fonts, use font.install(). BEWARE! This process takes a long time (~5-10 minutes for my computer). You can download the whole library of fonts or just a few. EVEN WINGDINGS! Oh god I find this so funny, its actually disturbing my lab mate a bit. Okay, so you can download lots of standard fonts. But what about non-standard fonts?…

Okay hang on for a minute, where did Wingdings come from? Like originally? It seems that back in the day, typesetters could issue non-standard types like the star of David, diamond, and circles and called them ‘dingbats’, which is what my mom used to call me when I was being a joker. Wingdings were developed by Microsoft back in the early 1990’s for their Windows 3.1, and have been available ever since.

Sorry for the aside.

If you find a non-standard type, you can download the .ttf file and install the text the same way that you would anything else.

So lets modify an example set that I found here (https://github.com/wch/extrafont); We will look at how temperature affects vapor pressure of mercury using the {pressure} dataset. For fun we will plot out our titles in Jokerman.

Rplot07

 ggplot(pressure, aes(x=temperature, y=pressure)) + geom_point() +
 ggtitle("Effect of Temp of Vapor Pressure of Mercury") +
 xlab("Temp") + ylab("Pressure") +
 theme(text=element_text(size=16, family="Jokerman"))

So that is kind of cool. I had previously seen people plot out stuff using numbers instead of dots or symbols. I thought that would be cool to see with some symbols from Wingdings (I swear I am not obsessed…)

Rplot087

 a=rnorm(100); plot(a,pch=(c("a","s","d","f","z","x","c","v","5")),family=windowsFont("Wingdings"))

As far as what to do if you want normal looking x and y labels, I have not figured that out yet. But a kind of a cool way to integrate new symbols beyond the regular {pch} crowd.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s