git cheatsheet

There are lots of good docs on git and github around. Perhaps, sometimes, too many! I am not attempting to add to them, just collating the specific sets of commands that I find useful in one place. I don’t promise they are useful for you, but the references to more complete docs may be.

Continue reading

Advertisements
Posted in git

ggplot2 cheatsheet

These are some of the most common things I want to do with ggplot2, but always forget the syntax (not helped when things are still evolving with each release!)

Titles, axis labels

  • main title
+ ggtitle("...")
  • set axis title (but see scale_x_continuous below)
+ xlab("...")
  • remove axis title, labels and tick marks (respectively)
+ theme(axis.title.x=element_blank(), 
        axis.text.x=element_blank(), 
        axis.ticks=element_blank())
  • make axis labels at a 45 degree angle
+ theme(axis.text.x = element_text(angle = 45, hjust = 1))
  • customize axis breaks and labels. title is optional, labels are optional and default to as.character(breaks)
scale_x_continuous("x axis title (optional)",
                   breaks=c(2000,5000),
                   labels=c("foo","bar"))
  • stretch axis to full width/length of plot
scale_x_continuous(expand=c(0,0))

Legend

  • no legend
+ theme(legend.position="none")