r - 如何在 R 中生成带有条形堆栈(不同颜色)的 gap.barplot?
问题描述
我想用堆栈生成 gap.barplot(例如:https ://www.eclipse.org/forums/index.php/t/487795/ )。但是,我不知道怎么做。或者,有没有办法在直方图中进行 y 轴中断?
这是我的数据:
dt <- structure(c(1162L, 699L, 20L, 26L, 2L, 4L, 1L, 11L, 2L, 8L, 5L,
15L, 2L, 23L, 3L, 25L, 3L, 30L, 0L, 24L, 0L, 23L, 1L, 14L, 0L,
4L, 1L, 1L, 0L, 2L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L,
0L), .Dim = c(2L, 21L), .Dimnames = structure(list(c("FALSE",
"TRUE"), c("0", "2", "4", "6", "8", "10", "12", "14", "16", "18",
"20", "22", "24", "26", "28", "30", "32", "34", "36", "38", "40"
)), .Names = c("", "")), class = "table")
我尝试使用包“plotrix”,如下所示,但没有成功。
library(plotrix)
# specifying the gap!
from <- 50
to <- 1830
# x axis
n1 <-seq(-1, 41, by=2)
n2 <- seq(0, 40, 2)
# actual plotting, but it does not work!
gap.barplot(dt, gap = c(from, to), xlab = "index", ylab = "number of points",
ytics=c(10, 20, 30, 40, 1810, 1840, 1860), xaxlab = n2, col=c("darkblue","red"),
legend = rownames(dt))
解决方案
推荐阅读
- python - 为什么 np.concatenate() 可以用于类'PIL.Image.Image'?
- iis - 无法在 GAC 中加载 HttpModule
- windows - 所有可能的 IIS 应用程序池状态是什么?
- html - 显示 flex flex wrap 宽度问题
- javascript - 从vue js中的多选框中检索选定的值
- swift - Reality Composer – 是否可以同时分配垂直和水平锚点?
- ios - 如何在 iOS 中获取路径扩展
- raspberry-pi - Camera Surveillance 应用程序将视频保存到服务器
- snowflake-cloud-data-platform - 雪花外部表需要后置列问题
- mysql - mysql:如果列具有值,则在某个表上进行左连接