Description Usage Arguments See Also Examples
Overwrites the default continuous fill scale with SGB-colors. To use
another palette or custom colours, use scale_fill_gradient()
.
1 2 3 4 5 6 7 8 9 10 | scale_fill_gradient(..., low = pal_sgb_rot[5], high = pal_sgb_rot[1])
scale_fill_gradient2(
...,
low = pal_sgb_dunkelblau[5],
mid = pal_sgb_hellblau[2],
high = pal_sgb_rot[5]
)
scale_fill_gradientn(..., colors, colours)
|
... |
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_colour_gradient()
,
scale_fill_discrete()
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 | ## Not run:
library(ggplot2)
library(gsgb)
theme_set(theme_sgb(base_size = 9))
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density))
# This gives the same:
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradient()
# Custom gradient colors:
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradient(low = pal_sgb_dunkelblau[5], high = pal_sgb_gelb[5])
# 3-color gradient (default):
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradient2(midpoint = .02)
# 3-color gradient (custom):
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradient2(low = pal_sgb_rot[5], mid = "white", high = pal_sgb_gelb[5],
midpoint = .02)
# n-colour gradient (default):
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_gradientn()
# n-colour gradient (custom):
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
scale_fill_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_bar(aes(fill = z1), stat = "identity") +
scale_fill_gradient(na.value = NA)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.