When I plot a stacked barplot in R, the bars are placed with equal gaps in between and the x axis values are just used as labels. I want to have the bars placed closer or farther apart based on the x axis values. Can someone help me get this plot using R?
Edit:
# data.frame newtest
A B C D
100 0.2 0.3 0.1 0.4
400 0.3 0.5 0.1 0.1
500 0.1 0.3 0.4 0.2
600 0.4 0.2 0.2 0.2
1000 0.1 0.5 0.1 0.3
1500 0.3 0.2 0.2 0.3
1600 0.4 0.1 0.3 0.2
1700 0.1 0.1 0.7 0.1
2500 0.3 0.2 0.1 0.4
# plot
barplot(t(as.matrix(newtest)), col = c("cyan", "lightblue", "yellow", "green"),
legend = colnames(newtest), cex.main = 0.5, cex.axis = 0.5,
cex.lab = 0.5, lwd = 0.02)
Here's the plot:
The bars are just labelled as per the row names. But I want the bars of 400,500,600 to be closer to each other, empty space to represent no blocks for 700,800,900, then the bar for 1000, then empty space till 1500, bars of 1500, 1600, 1700, etc.