A package that facilitates nice colors created for the Buenrostro Lab. The base of the package including some divergent color schemes were taken from the wesanderson package. This README provides a quick overview of how to use the color schemes with ggplot2 and which palettes are available.
To coordinate a ggplot feature (e.g. data point in a scatter plot) with a particular color, this post was a life-saver. Specifically, we’ll use a named vector to coordinate the discrete values. Here’s an example–
P.S.– this call will return a blank color for features that are not found in the color map (“ERY” in this example).
Important Note on color mappings…
The above ggplot command works because jdb_color_maps (with an ‘s’) exists as a named vector in the BuenColors NAMESPACE. The provided function (jdb_color_map) does not have an ‘s’ by the way. This same syntax of supplying a named vector should work for all discrete color scale functionalities in ggplot.
Discrete colors
The trick here is to use scale_color_manual like it is shown here–
Here’s what each palette looks like on a continuous scale.
Discrete colors
Here are the discrete color units that go into each scale. If n is small and discrete, note that the colors that are selected are read from left to right.
BuenColors
A package that facilitates nice colors created for the Buenrostro Lab. The base of the package including some divergent color schemes were taken from the wesanderson package. This README provides a quick overview of how to use the color schemes with ggplot2 and which palettes are available.
Installation
Color Palettes
With the library loaded, just type this to get either the
continuousordiscrete(by default) palette printed in yourplotconsole.Here are all the names that are available…
Color Maps
To keep consistent color designations, one can use the
color_mapfunction to link features to their specific hex color annoations. For example,returns the hex code associated with
HSCin the Buenrostro Lab paradigm. This function may be applied over multiple features–and will error out when a feature is not recognized–
Here are all the names that are available…
Here are what the mappings look like…
ggplot example
To coordinate a ggplot feature (e.g. data point in a scatter plot) with a particular color, this post was a life-saver. Specifically, we’ll use a named vector to coordinate the discrete values. Here’s an example–
P.S.– this call will return a blank color for features that are not found in the color map (“ERY” in this example).
Important Note on color mappings…
The above
ggplotcommand works becausejdb_color_maps(with an ‘s’) exists as a named vector in theBuenColorsNAMESPACE. The provided function (jdb_color_map) does not have an ‘s’ by the way. This same syntax of supplying a named vector should work for all discrete color scale functionalities inggplot.Discrete colors
The trick here is to use
scale_color_manuallike it is shown here–Continuous fill
The trick here is to use
scale_color_gradientnlike it is shown here–Density Plot
Best way that I’ve found to make the density color function represented in the points. Thanks to Kamil Slowikowski for figuring this out.
Shuffle Plot Order
Quick wrapper using
shufto change the order of plotting points (to a random presentation) to avoid hiding effects.Continuous Colors
Here’s what each palette looks like on a continuous scale.
Discrete colors
Here are the discrete color units that go into each scale. If n is small and discrete, note that the colors that are selected are read from left to right.