alphaPalette: Manipulate the transparency in a palette.

Description Usage Arguments Value Warning Author(s) See Also Examples

View source: R/plot.R

Description

Generate an color palette with changing transparency.

Usage

1
alphaPalette(x, f.seq, n = NULL)

Arguments

x

A vector with color values. Could be a single value specifying a single color palette, ranging in transparency values, or a vector with different colors.

f.seq

A vector with transparency values, ranging from 0 to 1.

n

Optional argument. A number specifying the number of colors in the palette. If n > 1, then N transparency values are generated ranging from the minimum of f.seq to the maximum of f.seq. n will only be used when the vector f.seq has two elements or more.

Value

A vector with color values.

Warning

On Linux x11 devices may not support transparency. In that case, a solution might be to write the plots immediately to a file using functions such as pdf, or png.

Author(s)

Jacolien van Rij

See Also

palette, colorRampPalette, adjustcolor, convertColor

Other Functions for plotting: addInterval(), add_bars(), add_n_points(), alpha(), check_normaldist(), color_contour(), dotplot_error(), drawDevArrows(), emptyPlot(), errorBars(), fill_area(), getCoords(), getFigCoords(), getProps(), gradientLegend(), legend_margin(), marginDensityPlot(), plot_error(), plot_image(), plotsurface(), sortBoxplot()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# a palette of 5 white transparent colors:
alphaPalette('white', f.seq=1:5/5)
# the same palette:
alphaPalette('white', f.seq=c(.2,1), n=5)
# a palette with 10 colors blue, yellow and red, that differ in transparency
alphaPalette(c('blue', 'yellow', 'red'), f.seq=c(0.1,.8), n=10)

emptyPlot(1,1, axes=FALSE, main='Tunnel of 11 squares')
mycol <- 'steelblue'
center <- c(.75, .25)
i = seq(0,1,by=.1)
fillcol <- alphaPalette(c(mycol, 'black'), f.seq=i)
linecol <- alphaPalette(mycol, f.seq=1-i)
rect(center[1]-center[1]*(1.1-i), center[2]-center[2]*(1.1-i), 
    center[1]+(1-center[1])*(1.1-i), center[2]+(1-center[2])*(1.1-i), 
    col=fillcol, border=linecol, lty=1, lwd=1, xpd=TRUE)

plotfunctions documentation built on April 28, 2020, 5:10 p.m.