作者:Zuguang Gu8
编译:Steven Shen
原文:Legends


第五章 图例

The heatmaps and simple annotations automatically generate legends which are put one the right side of the heatmap. By default there is no legend for complex annotations, but they can be constructed and added manually (Section 5.5). All legends are internally constructed by Legend() constructor. In later sections, we first introduce the settings for continuous legends and discrete legends, then we will discuss how to configure the legends associated with the heatmaps and annotations, and how to add new legends to the plot.

All the legends (no matter a single legend or a pack of legends) all belong to the Legends class. The class only has one slot grob which is the real grid::grob object or the grid::gTree object that records how to draw the graphics. The wrapping of the Legends class and the methods designed for the class make legends as single objects and can be drawn like points with specifying the positions on the viewport.

The legends for heatmaps and annotations can be controlled by heatmap_legend_param argument in Heatmap(), or annotation_legend_param argument in HeatmapAnnotation(). Most of the parameters in Legend() function can be directly set in the two arguments with the same parameter name. The details of setting heatmap legends and annotation legends parameters are introduced in Section 5.4.