Description Usage Arguments Details See Also Examples
Adds a color scale legend to the current plot with specified colors and range.
1 2 3 4 |
scale.colors |
a vector of colors |
scale.range |
range for scale (vector with 2 numeric elements, e.g. as returned by |
num.labs |
(default 6) number of text labels to draw |
pos |
(default topright)position for scale, either a keyword such as "top", "topleft" or a numeric vector length 2 |
adj |
controls the anchoring of the scale in respect to |
horiz |
TRUE for horizontal (default) or FALSE for vertical bar |
outside |
TRUE to display legend within the plotting area (default) or FALSE to place it outside |
size |
approximate length in inches |
ratio |
ratio of scale bar width to height |
tick.length |
number between 0 and 1, controls how long the ticks are vs the color boxes. |
scale.offset |
inset (outset) amount for legend that is inside (outside) |
label.offset |
spacing between ticks and text labels |
box |
this controls whether a black border is drawn around the colors or not. |
x.shift |
(optional) adjust x position in units of scale width. |
y.shift |
(optional) adjust y position in units of scale height. |
This function draws a color scale bar in the current plot. Position argument
pos
can be specified by keyword: 'center'
, 'middle'
,
'topleft'
, 'topright'
, 'top'
, 'bottomleft'
,
'bottomright'
, 'bottom'
, 'left'
, or 'right'
.
Alternately pos
can be set by specifying a numeric vector of length 2,
describing the x and y locations of legend, where each is a number between 0
(left/bottom) and 1 (right/top). The adj
argument controls the anchor
point for the legend itself relative to the plot. If unspecified, it will
match pos
, if outside
is FALSE
(default) or 1-pos
if outside
is TRUE
. This alignment is offset by scale.offset
so that the legend does not overlap the plot border.
The position can be further tweaked using the x.shift
and y.shift
arguments. 1 will shift the legend right/up by 1 scale width/height.
The size and shape of the color legend are controlled by size
, which
is the approximate length of the longer dimension in inches, and ratio
,
which is the ratio between width and height (or vice versa for vertical scale bars)
and should generally be > 1.
There are several arguments that control how the legend is drawn. The
tick.length
(between 0 and 1) argument controls how much of the shorter
dimension of the legend is taken up by the color scale vs the ticks. label.offset
controls the spacing between the ticks and the text labels. Parameters to modify
text size should be set via par()
prior to calling this function. Setting
box = FALSE
will remove the black outline around the colors.
draw.chrom.axis
for drawing x-axis
1 2 3 4 5 6 7 8 | plot(1:5, 1:5, col=gray(0:4/5), pch=15)
# Place a horizontal scale bar a the top, inside the plot.
draw.scale(gray(0:4/5), c(0, 1), pos='top')
# Place a vertical scale bar to the right, outside the plot.
draw.scale(gray(0:4/5), c(76.1, 76.92), pos='right', horiz=FALSE, outside=TRUE)
# Place a horizontal scale bar at the top left, outside the plot, but
aligned with the left edge of the plot
draw.scale(gray(0:4/5), c(1, 10), pos='topleft', adj=c(0, 0), outside=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.