emperor.Emperor.color_by

Emperor.color_by(category, colors=None, colormap=None, continuous=False)

Set the coloring settings for the plot elements

Parameters:

category: str

Name of the metadata column.

colors: dict or pd.Series, optional

Mapping of categories to a CSS color attribute. Defaults to the colors described by colormap.

colormap: str, optional

Name of the colormap to use. Supports continuous and discrete colormaps, see the notes section. Defaults to QIIME’s discrete colorscheme.

continuous: bool, optional

Whether or not the category should be interpreted as numeric.

Returns:

emperor.Emperor

Emperor object with updated settings.

Raises:

KeyError

If category is not part of the metadata.

TypeError

If category is not a string.

ValueError

If colors describes fewer or more categories than the ones present in the category column. If colors has colors in a non-string format.

See also

emperor.core.Emperor.visibility_by, emperor.core.Emperor.scale_by, emperor.core.Emperor.opacity_by, emperor.core.Emperor.shape_by, emperor.core.Emperor.set_background_color, emperor.core.Emperor.set_axes

Notes

Valid colormaps are listed below (under the Code column), for examples see [R6] or [R7].

Code Name Type
Paired Paired Discrete
Accent Accent Discrete
Dark2 Dark Discrete
Set1 Set1 Discrete
Set2 Set2 Discrete
Set3 Set3 Discrete
Pastel1 Pastel1 Discrete
Pastel2 Pastel2 Discrete
Viridis Viridis Sequential
Reds Reds Sequential
RdPu Red-Purple Sequential
Oranges Oranges Sequential
OrRd Orange-Red Sequential
YlOrBr Yellow-Orange-Brown Sequential
YlOrRd Yellow-Orange-Red Sequential
YlGn Yellow-Green Sequential
YlGnBu Yellow-Green-Blue Sequential
Greens Greens Sequential
GnBu Green-Blue Sequential
Blues Blues Sequential
BuGn Blue-Green Sequential
BuPu Blue-Purple Sequential
Purples Purples Sequential
PuRd Purple-Red Sequential
PuBuGn Purple-Blue-Green Sequential
Greys Greys Sequential
Spectral Spectral Diverging
RdBu Red-Blue Diverging
RdYlGn Red-Yellow-Green Diverging
RdYlB Red-Yellow-Blue Diverging
RdGy Red-Grey Diverging
PiYG Pink-Yellow-Green Diverging
BrBG Brown-Blue-Green Diverging
PuOr Purple-Orange Diverging
PRGn Purple-Green Diverging

References

[R6](1, 2) https://matplotlib.org/examples/color/colormaps_reference.html
[R7](1, 2) http://colorbrewer2.org/