image 和 barplot 的组合

代码示例:

par(mfrow = c(1, 2))

par(mar = c(1, 10, 1, 0), las = 1, ann = F)
image(1:10, 1:10,  matrix(sample(1:100), 10), xaxt = "n", yaxt = "n", axes = FALSE)
axis(side = 2, at = 1:10, labels = paste(letters[1:10], "124124214", sep = "") , tick = FALSE)
par(mar = c(1, 0, 1, 10))
barplot(1:10,  horiz = T, ylim = c(0.1, 10.1), yaxs = "i", width = 0.8, space = 0.25, xaxt = "n", border = NA)

效果图如下:

需要注意barplot 中space 函数的应用,space 的值为柱子宽度的百分比;

通过ylim 展示y轴的一部分;

 

posted on 2017-12-07 21:02  庐州月光  阅读(403)  评论(0编辑  收藏  举报