geom_shading_bar: Geom Layer for Drawing Shading Barplot

Description Usage Arguments Examples

View source: R/geom_shading_bar.R

Description

This function is similar to geom_bar(aes(x, y), stat="identity") except that it draws bars with shading colors. Unlike gg_shading_bar which is a convenient function, this function is used as a ggplot layer. Accepted properties are different from those in geom_multi_raster and gg_shading_bar.

NOTE: the function does interpolation as default, so you does not need to use interpolate parameter. And, unlike gg_shading_bar, this function does not draw lines around rectangles.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
geom_shading_bar(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  width = 0.9,
  flip = FALSE,
  modify_raster = TRUE,
  smooth = 15,
  equal_scale = FALSE,
  space = "rgb",
  orientation = "x",
  ...
)

Arguments

mapping

aes mapping.

data

data. It should be a tbl object.

stat

stat.

position

position. The parameter will not be used here.

na.rm

logical, whether to remove NA values.

show.legend

This will not be used because the layer does not create any legend.

inherit.aes

logical, whether to inherit aes from ggplot().

width

see description.

flip

see description.

modify_raster

see description or gg_shading_bar.

smooth

see description.

equal_scale

see description or gg_shading_bar.

space

see description.

orientation

see description.

...

additional parameters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Example 1: use vectors.
x=c("b", "a", "c", "d", "e")
y=c(2, 1, 3, 5, 4)
raster=list(c("blue", "red"), c("green", "orange"), 
	c("cyan", "yellow"), c("purple", "orangered"), c("grey", "red"))
ggplot()+
	geom_shading_bar(aes(x=x, y=y, raster=raster), smooth=40)
#
# Example 2: other parameters
x=1: 5
y=c(1, 2, -3, 5, 4)
raster=list(c("blue", "red"))
ggplot()+
	geom_shading_bar(aes(x=x, y=y, raster=raster), 
		smooth=50, width=0.6, equal_scale=TRUE)+
	scale_x_continuous(breaks=1: 5, labels=letters[1: 5])

Example output

Loading required package: ggplot2

plothelper documentation built on July 2, 2020, 4:03 a.m.