RSS Feed!

Recent Posts

Recent Comments

Archives

Categories

Meta

ggplot2 Color Consistency

I use the ggplot2 package in R for graphics in the analysis I perform for my clients.  In my current project I am analyzing the performance of 3 systems as compared to a base rate model.  Some of the charts include the base rate and a ground truth series, some exclude the base rate and some exclude the ground truth.  By the nature of the alphabetical ordering of the names for the systems, base rate, and ground truth, the color for a given system may be different on different charts.  It’s a minor thing, but consistency is better than inconsistency.  The answer is to use the scale_colour_manual and scale_fill_manual commands in ggplot2 to set the colors.  I have several lists of color settings, one for each combination that I wish to plot, wherein the color for a given system is consistent across settings.  Then, when I want to use the color settings I add a statement like “+ scale_colour_manual(values=’allSystemColors’)” to my ggplot command.

I found the page <http://sape.inf.usi.ch/quick-reference/ggplot2/colour> to be a handy reference to visually link the name of the color to the color itself.

By | 11. Feb 2014 | Uncategorized | Comments Off on ggplot2 Color Consistency

Comments are closed.