ColorScale: Color Scale

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

Description

Graded Color Scale position by locator

Usage

1
2
3
ColorScale(z, loc = list(x = 0, y = 0),  thick=1, len=1, offset=.2, col
= rainbow(100),border='black', gradcol='black',numbcol='black',  unitscol='black', 
units = "", SIDE = 1, font = 1, fontindex =1, cex=1)

Arguments

z

values to be scaled

loc

x-y location boundary of plotting area, user coordinates

thick

width of scale bar in inches

len

length of scale bar in inches

offset

offset from border, in inches

col

color palette

border

color for border of scale, NA=do not plot

gradcol

color for gradiation marks of scale, NA=do not plot

numbcol

color for number values of scale, NA=do not plot

unitscol

color for units character string, NA=do not plot

units

character, units for values

SIDE

side, 1,2,3,4 as in axis

font

vfont number

fontindex

font index number

cex

character expansion, see par for details

Details

Locations (loc) are given in User coordinates. The scale is plotted relative to the location provided in user coordinates and offset by so many inches outside that unit. to get a scale plotted on the interior of a plot, send ColorScale a rectangular box inside the plotting region and give it a 0 offset. All other measures are given in inches. To suppress the plotting of a particular item, indicate NA for its color.

Since the list of the bounding box is returned, this can be used to modify the text, e.g. change the way the units are displayed.

Value

list Graphical Side effects and list of bounding box for color scale:

x

x coordinates of box

y

y coordinates of box

Author(s)

Jonathan M. Lees<jonathan.lees@unc.edu>

See Also

HOZscale

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
data(volcano)

d = dim(volcano)
x=seq(from=1,by=1, length=d[1]+1)
y=seq(from=1,by=1, length=d[2]+1)
plot(range(x), range(y), type='n',  asp=1, ann=FALSE, axes=FALSE)

image(x=x, y=y, z=volcano, col = rainbow(100), add=TRUE)

z=volcano




ColorScale(volcano, loc=list(x=range(x), y=range(y)) ,
     col = rainbow(100), units = "Elev:m", font = 1, SIDE = 1)

ColorScale(volcano, loc=list(x=range(x), y=range(y)) ,
     col = rainbow(100), units = "Elev:m", font = 1, SIDE = 2)

ColorScale(volcano, loc=list(x=range(x), y=range(y)) ,
     col = rainbow(100), units = "Elev:m", font = 1, SIDE = 3)

ColorScale(volcano, loc=list(x=range(x), y=range(y)) ,
     col = rainbow(100), units = "Elev:m", font = 1, SIDE = 4)


plot(range(x), range(y), type='n',  asp=1, ann=FALSE, axes=FALSE)

##   image(x=x, y=y, z=volcano, col = rainbow(100), add=TRUE)

XAX = pretty(x)
XAX = XAX[XAX>=min(x)  & XAX<=max(x)]

axis(1, at=XAX, pos=y[1])

YAX = pretty(y)
YAX = YAX[YAX>=min(y)  & YAX<=max(y)]

axis(2, at=YAX, pos=x[1])

rect(x[1], y[1], max(x), max(y))



ColorScale(volcano, loc=list(x=range(x),  y=range(y)) ,offset=.8,
     col = rainbow(100), units = "Elev:m", font = 2, SIDE = 1)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.8 ,
     col = rainbow(100), units = "Elev:m", font = 1, fontindex = 2,SIDE = 2)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.2 ,
     col = rainbow(100), units = "Elev:m", font = 1, fontindex = 3, SIDE = 3)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.2 ,
     col = rainbow(100), units = "Elev:m", font = 2, fontindex = 3, SIDE = 4)


plot(range(x), range(y), type='n',  asp=1, ann=FALSE, axes=FALSE)

##   image(x=x, y=y, z=volcano, col = rainbow(100), add=TRUE)

XAX = pretty(x)
XAX = XAX[XAX>=min(x)  & XAX<=max(x)]

axis(1, at=XAX, pos=y[1])

YAX = pretty(y)
YAX = YAX[YAX>=min(y)  & YAX<=max(y)]

axis(2, at=YAX, pos=x[1])

rect(x[1], y[1], max(x), max(y))


ColorScale(volcano, loc=list(x=range(x),  y=range(y)) , offset=.8,  gradcol= NA, 
     col = rainbow(100), units = "Elev:m", font = 2, SIDE = 1)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.8 ,numbcol
= NA, 
     col = rainbow(100), units = "Elev:m", font = 1, fontindex = 2,SIDE = 2)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.2
,unitscol  = NA,
     col = rainbow(100), units = "Elev:m", font = 1, fontindex = 3, SIDE = 3)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.2 ,border
= NA, gradcol  = 'black', numbcol  = 'blue', unitscol  = 'purple', 
     col = rainbow(100), units = "Elev:m", font = 2, fontindex = 3, SIDE
= 4)


###########################

plot(range(x), range(y), type='n',  asp=1, ann=FALSE, axes=FALSE)

##   image(x=x, y=y, z=volcano, col = rainbow(100), add=TRUE)

XAX = pretty(x)
XAX = XAX[XAX>=min(x)  & XAX<=max(x)]

axis(1, at=XAX, pos=y[1])

YAX = pretty(y)
YAX = YAX[YAX>=min(y)  & YAX<=max(y)]

axis(2, at=YAX, pos=x[1])

rect(x[1], y[1], max(x), max(y))

B = ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.2 ,border
= NA, gradcol  = NA, numbcol  = NA, unitscol  = NA, 
     col = rainbow(100), units = "Elev:m", font = 2, fontindex = 3, SIDE = 3)

text(mean(B$x), B$y[2], "scaled data", pos=3, xpd=TRUE)

text(B$x[1], mean(B$y), min(volcano), pos=2,  xpd=TRUE)
text(B$x[2], mean(B$y), max(volcano), pos=4,  xpd=TRUE)



###########################   dark background
par(fg="white")
par(bg="black")
par(col.axis="white",   col.lab="white",  col.main="white",  col.sub="white") 

plot(range(x), range(y), type='n',  asp=1, ann=FALSE, axes=FALSE,
fg='white' )
image(x=x, y=y, z=volcano, col = rainbow(100), add=TRUE)

XAX = pretty(x)
XAX = XAX[XAX>=min(x)  & XAX<=max(x)]

axis(1, at=XAX, pos=y[1])

YAX = pretty(y)
YAX = YAX[YAX>=min(y)  & YAX<=max(y)]

axis(2, at=YAX, pos=x[1])

rect(x[1], y[1], max(x), max(y), border='white')


ColorScale(volcano, loc=list(x=range(x), y=range(y)) ,offset=.6, 
gradcol= 'black',  unitscol  =rgb(.9, .9, 1) ,  numbcol  =rgb(.9, 1, .9) , border="white",
     col = rainbow(100), units = "Elev:m", font = 2, fontindex = 3, SIDE = 1)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.8
,numbcol= rgb(1, .85, .85) , 
     col = rainbow(100), units = "Elev:m", font = 1, fontindex = 2,SIDE = 2)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.2,unitscol  = NA,
     col = rainbow(100), units = "Elev:m", font = 1, fontindex = 3, SIDE = 3)

ColorScale(volcano, loc=list(x=range(x), y=range(y)), offset=.2 ,border
= NA, gradcol  = 'white', numbcol  = 'blue', unitscol  = 'purple', 
     col = rainbow(100), units = "Elev:m", font = 2, fontindex = 3, SIDE = 4)





plot(range(x), range(y), type='n',  asp=1, ann=FALSE, axes=FALSE,
fg='white' )

XAX = pretty(x)
XAX = XAX[XAX>=min(x)  & XAX<=max(x)]

axis(1, at=XAX, pos=y[1])

YAX = pretty(y)
YAX = YAX[YAX>=min(y)  & YAX<=max(y)]

axis(2, at=YAX, pos=x[1])

rect(x[1], y[1], max(x), max(y), border='black')



ColorScale(volcano, loc=list(x=c(20, 40), y=c(10, 40)), thick=.2, offset=0 ,  
     col = rainbow(100), units = "Elev:m", font = 1, fontindex = 2,SIDE
= 2, cex=.5)

GEOmap documentation built on May 2, 2019, 8:56 a.m.