x1=c(3,5,6,9,375,190);
x1
x2=c(2,2,3,30,46,60);
x2
data=rbind(x1,x2);
data
colnames(data)=c("Pig","Layer","Broiler","Dairy","Beef","Sheep")
rownames(data)=c("1980","2010")
data
barplot(data,
beside=T,
ylab="Number of animal",
col=c("darkblue","red")
)
data_T=t(data);
data_T
library(reshape)
mdata <- melt(data_T, id=c("1980","2010"));
mdata
colnames(mdata)=c("Animal","Year",'value');
mdata
gap.barplot(mdata$value,
gap=c(200,340),
xlab="Animal",
ytics=c(0,50,100,150,200,300,350,400),
ylab="Number of animal",
xaxlab=mdata$Animal,
xaxt="n")
axis(side = 1, at = seq_along(mdata$Animal),mdata$Animal,tick = FALSE)
abline(h=seq(200,205,.001), col="white")
axis.break(axis=2,breakpos=202.5,style="slash")
But this is not quite what I want, because the bars (in gap.barplot) are not grouped like the previous hatch digits: (Then my questions are: how to make the broken y axis in the grouped lines of the barcode? In other words, how to combine function barplot and gap.barplot? Thanks a lot for your kind help!