Description Usage Arguments Details Value Author(s) See Also Examples
The imagebar_s
function is a tool for creating versatile stacked bar charts by filling the bars with external png and jpeg images.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | imagebar_s(
data,
x,
y,
group,
xlab = "",
ylab = "",
pattern.type,
label.size = 3.5,
frame.color = "black",
frame.size = 1,
legend.type = "h",
legend.h = 6,
legend.x.pos = 1.1,
legend.y.pos = 0.49,
legend.w = 0.2,
legend.pixel = 20,
legend.label,
bar.width = 0.9
)
|
data |
the data to be used. |
x |
the variable used on x axis. |
y |
the variable used on y axis. |
group |
the variable used as the second grouping variable on x axis. |
xlab |
a character string to give x axis label. |
ylab |
a character string to give y axis label. |
pattern.type |
a list of objects returned by |
label.size |
the font size of legend labels shown above the stacked bars. |
frame.color |
the color of the borders of the stacked bars. |
frame.size |
a numeric value, the line size for the borders of the stacked bars. |
legend.type |
if legend.type='h', the layout of legends is horizontal; if legend.type='v', the layout of legends is vertical. |
legend.h |
a numeric value to change the height of legend boxes. |
legend.x.pos |
a numeric value to change the position of legends on x axis. |
legend.y.pos |
a numeric value to change the position of legends on y axis. |
legend.w |
a numeric value to change the width of legends. |
legend.pixel |
a numeric value to change the pixel of legend boxes. |
legend.label |
a vector to name legend labels. |
bar.width |
a numeric value to change the width of the bars. |
imagebar_s
function offers flexible ways of doing stacked bar charts.
A ggplot object.
Chunqiao Luo (chunqiaoluo@gmail.com)
Function patternbar_s
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(patternplot)
library(jpeg)
library(ggplot2)
childcare<-readJPEG(system.file("img", "childcare.jpg", package="patternplot"))
food<-readJPEG(system.file("img", "food.jpg", package="patternplot"))
housing <-readJPEG(system.file("img", "housing.jpg", package="patternplot"))
data <- read.csv(system.file("extdata", "monthlyexp.csv", package="patternplot"))
x<-data$Location
y<-data$Amount
group<-data$Type
pattern.type<-list(childcare, food, housing)
imagebar_s(data,x,y,group,xlab='',ylab='Monthly Expenses, Dollar',pattern.type=pattern.type,
label.size=3.5,frame.size=1,frame.color='black',legend.type='h',legend.h=6,legend.y.pos=0.49,
legend.pixel=20, legend.w=0.2,legend.x.pos=1.1,
legend.label=c("Childcare", "Food", "Housing"))+scale_y_continuous(limits = c(0, 6800))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.