Description Usage Arguments Examples
View source: R/geom-textured-bar.R
geom_textured_bar()
and geom_textured_col()
are equivalent to
geom_bar()
and geom_col()
but draw textured columns just like
geom_textured_rect()
does.
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 | geom_textured_bar(
mapping = NULL,
data = NULL,
stat = "count",
position = "stack",
...,
img_width = unit(1, "null"),
img_height = NA,
nrow = NA,
ncol = NA,
interpolate = TRUE,
legend_key_params = NULL,
width = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_textured_col(
mapping = NULL,
data = NULL,
stat = "identity",
position = "stack",
...,
interpolate = TRUE,
width = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
|
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
Override the default connection between |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
img_width |
Unit object specifying the width of the texture image.
If |
img_height |
Unit object specifying the height of the texture image.
If |
nrow |
Number of image rows. If |
ncol |
Number of image columns. If |
interpolate |
A logical value indicating whether to linearly interpolate the image (the alternative is to use nearest-neighbour interpolation, which gives a more blocky result). |
legend_key_params |
A list holding additional parameters to be handed off
to |
width |
Bar width. By default, set to 90% of the resolution of the data. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
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 | library(ggplot2)
library(tibble)
# textured columns
df <- tibble(
trt = c("a", "b", "c"),
outcome = c(2.3, 1.9, 3.2),
image = c(
"http://www.hypergridbusiness.com/wp-content/uploads/2012/12/rocks2-256.jpg",
"http://www.hypergridbusiness.com/wp-content/uploads/2012/12/stone2-256.jpg",
"http://www.hypergridbusiness.com/wp-content/uploads/2012/12/siding1-256.jpg"
)
)
ggplot(df, aes(trt, outcome, image = image)) +
geom_textured_col()
# textured bars
images = c(
compact = "http://www.hypergridbusiness.com/wp-content/uploads/2012/12/rocks2-256.jpg",
midsize = "http://www.hypergridbusiness.com/wp-content/uploads/2012/12/stone2-256.jpg",
suv = "http://www.hypergridbusiness.com/wp-content/uploads/2012/12/siding1-256.jpg",
`2seater` = "http://www.hypergridbusiness.com/wp-content/uploads/2012/12/mulch1-256.jpg",
minivan = "http://www.hypergridbusiness.com/wp-content/uploads/2012/12/rocks1-256.jpg",
pickup = "http://www.hypergridbusiness.com/wp-content/uploads/2012/12/wood3-256.jpg",
subcompact = "http://www.hypergridbusiness.com/wp-content/uploads/2012/12/concrete1-256.jpg"
)
ggplot(mpg, aes(class, image = class)) +
geom_textured_bar() +
scale_image_manual(values = images)
ggplot(mpg, aes(factor(trans), image = class)) +
geom_textured_bar() +
scale_image_manual(values = images)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.