在直方图中创建轴间隙
我试图在0.6和1之间的直方图(在Y轴上)中创建差距,但真的不知道该如何解决。 gap.barplot解决方案似乎不起作用,我很乐意保持与其他景观一致的美感。理想情况下,它看起来像这样:
h <- hist(benthosBx$length_mm, breaks = seq(0, 10, 0.5), plot = FALSE)
h$counts <- h$counts / nrow(benthosBx)
gap.plot(h, xlab = 'Body length (mm)', ylab = '', gap = c(0.4,0.8),ylim = c(0,0.6), xlim = c(0,10), main = ' ', xaxt='n', yaxt='n', col = "grey")
axis(side=1, at=seq(0,10, 1))
axis(side=2, at=seq(0,1, 0.1))
structure(list(lakeID = c("WE2", "WE2"), length_mm = c(1.52172197930582,
1.63884515191493), date = structure(c(1592352000, 1597881600), tzone = "UTC", class = c("POSIXct",
"POSIXt")), year = c(2020L, 2020L)), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame"))
I'm trying to create a gap in a histogram between 0.6 and 1 (on the y axis) but don't really know how to go about this. The gap.barplot solution does not seem to work and i'd love to keep the aesthetic of the plots consistent with the other ones. Ideally it would look something like this:
The general plot code attempt looks like this:
h <- hist(benthosBx$length_mm, breaks = seq(0, 10, 0.5), plot = FALSE)
h$counts <- h$counts / nrow(benthosBx)
gap.plot(h, xlab = 'Body length (mm)', ylab = '', gap = c(0.4,0.8),ylim = c(0,0.6), xlim = c(0,10), main = ' ', xaxt='n', yaxt='n', col = "grey")
axis(side=1, at=seq(0,10, 1))
axis(side=2, at=seq(0,1, 0.1))
dput of the data:
structure(list(lakeID = c("WE2", "WE2"), length_mm = c(1.52172197930582,
1.63884515191493), date = structure(c(1592352000, 1597881600), tzone = "UTC", class = c("POSIXct",
"POSIXt")), year = c(2020L, 2020L)), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame"))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将值设置为零。
Set the value to zero.
Data: