Description Usage Arguments See Also Examples
Overwrites the default continuous color scale with SGB-colors. To use
another palette or custom colours, use scale_color_gradient()
.
1 2 3 4 5 6 7 8 9 10 | scale_colour_gradient(..., low = pal_sgb_rot[5], high = pal_sgb_rot[1])
scale_colour_gradient2(
...,
low = pal_sgb_dunkelblau[5],
mid = pal_sgb_hellblau[2],
high = pal_sgb_rot[5]
)
scale_colour_gradientn(..., colours = pal_sgb, colors = pal_sgb)
|
... |
parameters passed on to |
low, high |
Colours for low and high end of the gradient |
mid |
Colour for mid point |
colors, colours |
Vector of colours to use for n-colour gradient. |
Other colour scales:
scale_colour_discrete()
,
scale_fill_discrete()
,
scale_fill_gradient()
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 | ## Not run:
library(ggplot2)
library(gsgb)
theme_set(theme_sgb(base_size = 9))
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(color = Sepal.Length))
# This gives the same:
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(color = Sepal.Length)) +
scale_color_gradient()
# Custom gradient colors:
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(color = Sepal.Length)) +
scale_color_gradient(low = pal_sgb_dunkelblau[5], high = pal_sgb_gelb[5])
# 3-color gradient (default):
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(color = Sepal.Length)) +
scale_color_gradient2(midpoint = 6)
# 3-color gradient (custom):
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(color = Sepal.Length)) +
scale_color_gradient2(low = pal_sgb_rot[5], mid = "white", high = pal_sgb_gelb[5],
midpoint = 6)
# n-color gradient (default):
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(color = Sepal.Length)) +
scale_color_gradientn()
# n-color gradient (custom):
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(color = Sepal.Length)) +
scale_color_gradientn(colors = pal_sgb_pref)
# Use `na.value = NA` to hide missing values but keep the original axis range
df_na <- data.frame(
value = seq(1, 20),
x = runif(20),
y = runif(20),
z1 = c(rep(NA, 10), rnorm(10)))
ggplot(df_na, aes(x = value, y)) +
geom_point(aes(color = z1)) +
scale_color_gradient(na.value = NA)
# or select custom color for missing values
ggplot(df_na, aes(x = value, y)) +
geom_point(aes(color = z1)) +
scale_color_gradient(na.value = SGBdunkelblau)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.