Ecologists: what we do vs. what we want people to think that we do

This occurred to me the other day while out working in the field for a day. I think back on all the photos I’ve posted of me doing rad stuff outside for work, like skiing through northern forests, flying around in helicopters, building cool stuff on glaciers, and the like. And then I think about all the photos I haven’t posted of me sitting at my desk (the number is non-zero, but just)…

Ecologist Pie Chart

It’s not that we’re trying to be disingenuous. Rather, I think we all really wish we did more rad stuff and less sitting at a computer. But at the end of the day, data needs cleaning and analysing, papers need writing, and grants need granting. So it goes.

And of course, I’ve included the code to create this in R. This script shows a couple of potentially useful things like how to make a pie chart in ggplot2 (not that intuitive). Also, it captures the delightfully informal feel of the xkcd comics, thanks to the wonderful xkcd package for R.

## http://xkcd.r-forge.r-project.org/
# install.packages("xkcd")
library(xkcd)

## Make the xkcd plotting theme
## https://stackoverflow.com/questions/12675147/how-can-we-make-xkcd-style-graphs
theme_xkcd <- theme(
 panel.background = element_rect(fill="white"), 
 axis.ticks = element_line(colour=NA),
 panel.grid = element_line(colour="white"),
 axis.text.y = element_text(colour=NA), 
 axis.text.x = element_text(colour="black"),
 text = element_text(size=16, family="xkcd")
)

## Make the data (adjust proportions to suit your lifestyle)
work <- data.frame(Task=c("Sitting in front of a computer","Doing rad stuff outside"), Prop=c(0.99,0.01))
photos <- data.frame(Task=c("Sitting in front of a computer","Doing rad stuff outside"), Prop=c(0.01,0.99))

## Make the pie charts
## http://www.sthda.com/english/wiki/ggplot2-pie-chart-quick-start-guide-r-software-and-data-visualization
p.time <- ggplot(work, aes(x="", y=Prop, fill=Task)) +
 geom_bar(stat="identity", width=1) +
 coord_polar("y", start=1.6) +
 scale_fill_manual(values=c("red2","lightblue3")) +
 guides(fill=guide_legend(nrow=2)) +
 labs(y="Ecologist work time spent", fill="") +
 theme_xkcd() + 
 theme(legend.position = "bottom",
 axis.text = element_blank(),
 axis.ticks = element_blank(),
 axis.title.y = element_blank(),
 axis.title.x = element_text(size=rel(1.3)),
 legend.text = element_text(size=rel(1)))

p.photos <- ggplot(photos, aes(x="", y=Prop, fill=Task)) +
 geom_bar(stat="identity", width=1) +
 coord_polar("y", start=1.55) +
 scale_fill_manual(values=c("red2","lightblue3")) +
 guides(fill=guide_legend(nrow=2)) +
 labs(y="Ecologist photos on social media", fill="") +
 theme_xkcd() + 
 theme(legend.position = "bottom",
 axis.text = element_blank(),
 axis.ticks = element_blank(),
 axis.title.y = element_blank(),
 axis.title.x = element_text(size=rel(1.3)),
 legend.text = element_text(size=rel(1)))

## Save the plots as a PNG
png("Ecologist Pie Chart.png", h=400, w=650)
grid.arrange(p.time, p.photos, ncol=2)
dev.off()

 

Advertisements
This entry was posted in graphics, R. Bookmark the permalink.

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