Description Usage Arguments Details Value Author(s) See Also Examples
The imagebar
function is a tool for creating versatile 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 21 |
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. |
label.size |
the font size of legend labels shown above the bars. |
vjust |
the vertical distance of labels from the top border of each bar. |
hjust |
the horizontal distance of labels from the top border of each bar. |
pattern.type |
a list of objects returned by |
frame.color |
the color of the borders of bars. |
frame.size |
a numeric value, the line size for the borders of 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 |
bar.width |
a numeric value to change the width of the bars. |
imagebar
function offers flexible ways of doing bar charts.
A ggplot object.
Chunqiao Luo (chunqiaoluo@gmail.com)
Function patternbar
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 | 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"))
#Example 1
data <- read.csv(system.file("extdata", "monthlyexp.csv", package="patternplot"))
data<-data[which(data$Location=='City 1'),]
x<-factor(data$Type, c('Housing', 'Food', 'Childcare'))
y<-data$Amount
pattern.type<-list(housing, food, childcare)
imagebar(data,x, y,group=NULL,pattern.type=pattern.type,vjust=-1, hjust=0.5,
frame.color='black',ylab='Monthly Expenses, Dollars')+ggtitle('(A) Bar Chart with Images')
#Example 2
data <- read.csv(system.file("extdata", "monthlyexp.csv", package="patternplot"))
group<-factor(data$Type, c('Housing', 'Food', 'Childcare'))
y<-data$Amount
x<-factor(data$Location, c('City 1', ' City 1'))
pattern.type<-list(housing, food, childcare)
g<-imagebar(data,x,y,group,pattern.type=pattern.type,vjust=-1,hjust=0.5,frame.color='black',
ylab='Monthly Expenses, Dollars')+ggtitle('(B) Image Bar Chart with Two Grouping Variables')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.