All Projects → Selbosh → ggChernoff

Selbosh / ggChernoff

Licence: other
R package for drawing Chernoff faces in ggplot2

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to ggChernoff

Ggthemes
Additional themes, scales, and geoms for ggplot2
Stars: ✭ 1,107 (+3853.57%)
Mutual labels:  ggplot2, plot
emojifont
🍭Emoji and fontawesom in both base and ggplot2 graphics
Stars: ✭ 61 (+117.86%)
Mutual labels:  emoji, ggplot2
Ggplotnim
A port of ggplot2 for Nim
Stars: ✭ 95 (+239.29%)
Mutual labels:  ggplot2, plot
gameofthrones
🎨 Game of Thrones inspired palette for R
Stars: ✭ 69 (+146.43%)
Mutual labels:  ggplot2, plot
Gglabeller
Shiny gadget for labeling points on ggplot
Stars: ✭ 161 (+475%)
Mutual labels:  ggplot2, plot
ggquiver
R package for quiver plots in 'ggplot2'
Stars: ✭ 38 (+35.71%)
Mutual labels:  ggplot2, plot
DataViz-Teaching
📈 Visualizations for DataViz Teaching
Stars: ✭ 29 (+3.57%)
Mutual labels:  ggplot2
microbiomeViz
Visualize microbiome data with black magic ggtree
Stars: ✭ 55 (+96.43%)
Mutual labels:  ggplot2
MCUCapture
Utility for plotting array data from MCU RAM
Stars: ✭ 22 (-21.43%)
Mutual labels:  plot
Emojilog
A nice little diary for emoji logs.
Stars: ✭ 12 (-57.14%)
Mutual labels:  emoji
printer
A fancy logger yet lightweight, and configurable. 🖨
Stars: ✭ 65 (+132.14%)
Mutual labels:  emoji
slack-emoji-for-techies
100s of Slack emoji, many tech-related
Stars: ✭ 123 (+339.29%)
Mutual labels:  emoji
emoji-extractor-plus
Extract emojis from Apple font in PNG format
Stars: ✭ 42 (+50%)
Mutual labels:  emoji
RBitmoji
An R wrapper to the overly complicated Bitmoji API 😱
Stars: ✭ 25 (-10.71%)
Mutual labels:  emoji
latexemoji
Latex package to include emoji in Latex document
Stars: ✭ 17 (-39.29%)
Mutual labels:  emoji
SWDchallenge
📈 My contributions to the #SWDchallenge
Stars: ✭ 20 (-28.57%)
Mutual labels:  ggplot2
awesome-twitter-bots
A Curated Collection of the Best Twitter Bots 🤖
Stars: ✭ 99 (+253.57%)
Mutual labels:  emoji
unicode-emoji-json
Emoji data from unicode.org as easily consumable JSON files.
Stars: ✭ 149 (+432.14%)
Mutual labels:  emoji
EasyEmoji
Help developers to quickly realize the expression of the keyboard
Stars: ✭ 24 (-14.29%)
Mutual labels:  emoji
parcours-r
Valise pédagogique pour la formation à R
Stars: ✭ 25 (-10.71%)
Mutual labels:  ggplot2

Draw Chernoff faces in ggplot2

Build Status AppVeyor Build Status CRAN_Status_Badge

This silly package, ggChernoff, introduces a geom_chernoff geom for ggplot2. This works a bit like geom_point, but draws little smiley faces (emoticons) instead of dots.

The Chernoff geom has some unique aesthetics, including smile, which makes your faces smile or frown according to the relative magnitude of your continuous variable. By default, the mean value will generate a straight face 😑 while higher values will make smiles 😊 and lower values will draw frowns 😢. You can customise this using scale_smile. If smile is unmapped to a variable, all faces will be happy by default.

Eyebrows are hidden by default, but you can activate them by mapping something to the brow aesthetic. High values make your faces angry 😠 and low values the opposite 😧.

Getting started

Install the package using

devtools::install_github('Selbosh/ggChernoff')

and then load it using

library(ggChernoff)

Examples

Firstly, let's create a scatter plot of smiley faces out of Fisher's iris data set, each one coloured according to species.

library(ggplot2)
ggplot(iris) +
  aes(Petal.Width, Petal.Length, fill = Species) +
  geom_chernoff()

Here is an example using Immer's barley data. We are happy about larger yields!

ggplot(lattice::barley) +
  aes(year, variety, smile = yield, brow = yield) +
  geom_chernoff(fill = 'goldenrod1') +
  scale_x_discrete(limits = c('1931', '1932')) +
  facet_wrap(~ site)

Basic legends are now supported. We can customise breaks and titles in the usual ggplot2 way, via scale_smile_continuous.

g <- ggplot(data.frame(x = rnorm(20), y = rexp(20), z = runif(20))) +
  aes(x, y, smile = z) +
  geom_chernoff(fill = 'steelblue1')
g

g + scale_smile_continuous('Smilez', breaks = 0:10/10, midpoint = .5)

You can also use this command to adjust the range of possible happiness/sadness in your plot. In the following example, everybody is somewhere between sad and straight-faced.

g + scale_smile_continuous(range = c(-1, 0))

Space invaders! 👽

cannon <- data.frame(x = 0, y = 0, colour = 'white', size = 20)
bunkers <- data.frame(x = seq(-4, 4, l = 4), y = 2, colour = 'green', size = 1)
ufos <- data.frame(x = rep(seq(-6, 6, length.out = 12), 5),
                   y = rep(6:10, each = 12), size = 10,
                   colour = c('cyan', 'yellow', 'magenta')[
                     c(rep(1:3,4), rep(c(2,3,1),4), rep(c(3,1,2),4), rep(1:3,4), rep(c(2,3,1),4))
                     ],
                   brow = rnorm(60))
ggplot(ufos) +
  aes(x, y, fill = colour, size = size) +
  geom_chernoff(smile = -1, aes(brow = brow)) +
  geom_chernoff(data = cannon) +
  geom_tile(data = bunkers, width = 1) +
  geom_tile(data = data.frame(x = 0, y = 3, colour = 'white', size = 2), width = .1) +
  scale_fill_identity() +
  scale_size_identity() +
  theme_void() +
  theme(plot.background = element_rect(fill = 'black'),
        legend.position = 'none')

References

Hermann Chernoff (1973). The use of faces to represent points in k-dimensional space graphically. Journal of the American Statistical Association, 68(342), 361–368.

Leland Wilkinson (2006). The Grammar of Graphics (2nd edition). Springer.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].