R bloggers

Putting the cat in scatterplot

FavoriteLoadingAdd to favorites

Clara Schartner, Data Scientist It will come as no surprise that cats and ggplot are among our favourite things here at Mango, luckily there is an easy way to combine both. Using the function annotation_custom in the popular ggplot2 package it is possible to display images on a plot i.e. points of a scatterplot. This way data can be displayed in a more fun, creative way. In keeping with the cat theme I have chosen a data set about cats and a cat icon based on Mango the cat. The MASS package provides a data set called cats which contains the body weight, heart weight and sex of adult cats. library(MASS) data(cats) head(cats) set.seed(1234) cats <- cats[sample(1:144, size = 40),] First a normal scatterplot is defined on which the images will be plotted later: library(ggplot2) sCATter <-ggplot(data = cats, aes(x…
Original Post: Putting the cat in scatterplot