| 1 |
# Outside of domain returns na.color |
| 2 |
|
| 3 |
Code |
| 4 |
col_factor(bw, letters, na.color = NA)("foo") |
| 5 |
Condition |
| 6 |
Warning: |
| 7 |
Some values were outside the color scale and will be treated as NA |
| 8 |
Output |
| 9 |
[1] NA |
| 10 |
|
| 11 |
--- |
| 12 |
|
| 13 |
Code |
| 14 |
col_quantile(bw, 0:1, na.color = NA)(-1) |
| 15 |
Condition |
| 16 |
Warning: |
| 17 |
Some values were outside the color scale and will be treated as NA |
| 18 |
Output |
| 19 |
[1] NA |
| 20 |
|
| 21 |
--- |
| 22 |
|
| 23 |
Code |
| 24 |
col_quantile(bw, 0:1, na.color = NA)(2) |
| 25 |
Condition |
| 26 |
Warning: |
| 27 |
Some values were outside the color scale and will be treated as NA |
| 28 |
Output |
| 29 |
[1] NA |
| 30 |
|
| 31 |
--- |
| 32 |
|
| 33 |
Code |
| 34 |
col_numeric(bw, c(0, 1), na.color = NA)(-1) |
| 35 |
Condition |
| 36 |
Warning: |
| 37 |
Some values were outside the color scale and will be treated as NA |
| 38 |
Output |
| 39 |
[1] NA |
| 40 |
|
| 41 |
--- |
| 42 |
|
| 43 |
Code |
| 44 |
col_numeric(bw, c(0, 1), na.color = NA)(2) |
| 45 |
Condition |
| 46 |
Warning: |
| 47 |
Some values were outside the color scale and will be treated as NA |
| 48 |
Output |
| 49 |
[1] NA |
| 50 |
|
| 51 |
# factors match by name, not position |
| 52 |
|
| 53 |
Code |
| 54 |
col <- pal(letters[10:20]) |
| 55 |
Condition |
| 56 |
Warning: |
| 57 |
Some values were outside the color scale and will be treated as NA |
| 58 |
|
| 59 |
# qualitative palettes don't interpolate |
| 60 |
|
| 61 |
Code |
| 62 |
pal(letters[6]) |
| 63 |
Condition |
| 64 |
Warning: |
| 65 |
Some values were outside the color scale and will be treated as NA |
| 66 |
Output |
| 67 |
[1] NA |
| 68 |
|
| 69 |
# OK, qualitative palettes sometimes interpolate |
| 70 |
|
| 71 |
Code |
| 72 |
result <- pal(letters[1:20]) |
| 73 |
Condition |
| 74 |
Warning in `RColorBrewer::brewer.pal()`: |
| 75 |
n too large, allowed maximum for palette Accent is 8 |
| 76 |
Returning the palette you asked for with that many colors |
| 77 |
|
| 78 |
# col_quantile handles skewed data |
| 79 |
|
| 80 |
Code |
| 81 |
x <- c(1:5, rep(10, 10)) |
| 82 |
col <- col_quantile("RdYlBu", domain = x, n = 7)(x) |
| 83 |
Condition |
| 84 |
Warning: |
| 85 |
Skewed data means we can only allocate 4 unique colours not the 7 requested |
| 86 |
Code |
| 87 |
col <- col_quantile("RdYlBu", domain = NULL, n = 7)(x) |
| 88 |
Condition |
| 89 |
Warning: |
| 90 |
Skewed data means we can only allocate 4 unique colours not the 7 requested |
| 91 |
|