set.colorbar {oceanmap} | R Documentation |
Adds colorbar to an extisting plot device
Description
Adds colorbar to an extisting plot device. If position vectors are not provided, the user will be asked to define the colorbar placement by the mouse cursor.
Usage
set.colorbar(cbx, cby, cbpos, cbline=0, pal='jet', zlim, ticks=1:10, labels=ticks,
gradient, oticks, cb.title="", cb.xlab="", font=1, cex=1,
cex.cb.title=0.9, cex.cb.xlab=0.8, cex.cb.ticks=0.7, cb.ticks.srt=90,
cb.ticks.length, cb.ticks.ypos, cb.ticks.lwd=1,
integer=F, cb.xlab.line=0, total.reg, cbxp, cbyp,...)
set.colorbarp(cbxp, cbyp, total.reg=T, year_bar=F, pal="jet",...)
Arguments
cbx , cby |
( |
cbxp , cbyp |
( |
cbpos |
letter ("b", "l", "t", "r") indicating the position of the colorbar (bottom, left, top, right). Overwrites |
cbline |
distance to default location of the colorbar, starting at 0. |
total.reg |
( |
year_bar |
whether to plot a colorbar with monthly ticks (by default |
pal |
color map to be plotted (default is |
zlim |
(optional) value limits of the color bar. Overwrites ticks if ticks are povided. |
ticks |
the points at which tick-marks are to be drawn (default is 1:10). Non-finite (infinite, NaN or NA) values are omitted. Gets verwritten by zlim if povided. |
labels |
character or expression vector of labels to be placed at the tickpoints. (default equals |
gradient |
whether to have a horizontal (x) or vertical (y) color gradient. |
oticks |
the margin where to put the colorbar ticks relative to the colorbar rectangle ( |
cb.title |
character string indicating the title of the colorbar (default is set to date information/empty string if date information is missing.) |
cb.xlab |
character string indicating the x-axis label of the colorbar. |
font |
Integer specifying font to use for text. 1=plain [default], 2=bold, 3=italic, 4=bold italic, 5=symbol |
cb.xlab.line |
line of x-axis colorbar label |
cex , cex.cb.title , cex.cb.xlab , cex.cb.ticks |
cex: general font size, used as reference for colorbar labels and title cex.cb.xlab: font size of the x-axis label of the colorbar cex.cb.title: font size of the title of the colorbar |
cb.ticks.srt , cb.ticks.length , cb.ticks.ypos , cb.ticks.lwd |
rotation, length, relative y-position and line width of colorbar ticks |
integer |
(default is |
... |
additional arguments to be passed to text or |
Details
set.colobar
adds a colorbar to the current plot device. If colorbar positions are missing (cbx
, cby
), the user will be asked for manual placement. ticks
and tick-labels
should correspond to zlim
-values of the plot. pal
defines the colormap and should equal col
of the selected plot.
Value
a list of colorbar definition vectors: oticks, gradient, cbx
and cby
. See function argmuments for more details.
Author(s)
Robert K. Bauer
Examples
## Example 1: plot colorbars manually
par(mar=c(8,8,8,8))
plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1))
set.colorbar(cbx=c(0, 1), cby=c(-.3, -.4)) # bottom
set.colorbar(cby=c(0, 1), cbx=c(-.4, -.3)) # left
set.colorbar(cbx=c(0, 1), cby=c(1.2, 1.3)) # top
set.colorbar(cby=c(0, 1), cbx=c(1.2, 1.3)) # right
## Example 2: use cbpos
par(mar=c(8,8,8,8))
plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1))
set.colorbar(cbpos='b') # bottom
set.colorbar(cbpos='l') # left
set.colorbar(cbpos='t') # top
set.colorbar(cbpos='r') # right
## Example 3: interactive placement
# par(mar=c(8,8,8,8))
# plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1))
# cb <- set.colorbar() # interactive
# plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1))
# set.colorbar(cbx=cb$cbx, cby=cb$cby) # reuse stored colorbar positions