Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

draw-Legends-method

Draw the Legends


Description

Draw the Legends

Usage

## S4 method for signature 'Legends'
draw(object, x = unit(0.5, "npc"), y = unit(0.5, "npc"), just = "centre", test = FALSE)

Arguments

object

The grob object returned by Legend or packLegend.

x

The x position of the legends, measured in current viewport.

y

The y position of the legends, measured in current viewport.

just

Justification of the legends.

test

Only used for testing.

Details

In the legend grob, there should always be a viewport attached which is like a wrapper of all the graphic elements in a legend. If in the object, there is already a viewport attached, it will modify the x, y and valid.just of the viewport. If there is not viewport attached, a viewport with specified x, y and valid.just is created and attached.

You can also directly use grid.draw to draw the legend object, but you can only control the position of the legends by first creating a parent viewport and adjusting the position of the parent viewport.

Examples

lgd = Legend(at = 1:4, title = "foo")
draw(lgd, x = unit(0, "npc"), y = unit(0, "npc"), just = c("left", "bottom"))

# and a similar version of grid.draw
pushViewport(viewport(x = unit(0, "npc"), y = unit(0, "npc"), just = c("left", "bottom")))
grid.draw(lgd)
popViewport()

ComplexHeatmap

Make Complex Heatmaps

v2.6.2
MIT + file LICENSE
Authors
Zuguang Gu
Initial release
2020-11-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.