| annoLegend | R Documentation |
This function is used to add legend annotations in plot.
annoLegend( object = NULL, relPos = c(0.9, 0.9), xPosition = NULL, yPosition = NULL, labels = NULL, vgap = 1, hgap = 1, cex = 1, pch = NULL, ncol = 1, col = NULL, fill = NULL, do.lines = FALSE, lines.first = FALSE, textSize = NULL, fontfamily = NULL, fontface = NULL )
object |
This function is used to add segment annotations in plot. |
relPos |
The relative position of legend. Default(c(0.9,0.9)). |
xPosition |
The x axis coordinate for the legend. Default(NULL). |
yPosition |
The x axis coordinate for the legend. Default(NULL). |
labels |
The legend text labels. Default(NULL). |
vgap |
Vertical space between the legend entries. Default(1). |
hgap |
Horizontal space between the legend entries. Default(1). |
cex |
The legend key size. Default(1). |
pch |
Legend shape. Default(NULL). |
ncol |
Legend columns to show. Default(NULL). |
col |
Legend colors. Default(NULL). |
fill |
Legend fill colors. Default(NULL). |
do.lines |
Whether to show lines. Default(FALSE). |
lines.first |
Whether to show lines first. Default(FALSE). |
textSize |
Legend text size. Default(NULL). |
fontfamily |
Legend text fontfamily. Default(NULL). |
fontface |
Legend text fontface. Default(NULL). |
Return a ggplot object.
Junjun Lao
# ===============================
# test function
# load data
data(p)
# add legend
annoLegend(object = p,
labels = paste('legend ',1:5),
pch = 21,
col = 'black',
fill = useMyCol('paired',5),
textSize = 15)
# change pos
annoLegend(object = p,
relPos = c(0.2,0.9),
labels = paste('legend ',1:5),
pch = 21,
col = 'black',
fill = useMyCol('paired',5),
textSize = 15)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.