【问题标题】:Plotting pre-binned data of percent time allotments [duplicate]绘制百分比时间分配的预分箱数据[重复]
【发布时间】:2013-08-09 00:17:55
【问题描述】:

我在单个 data.frame 中有 11 个数据列,其中 10 个列是深度类别,一列包含两个值之一(DayNight)。

每一行数据都填充了代表在 4 小时内每个深度类别花费的时间百分比的数值,并在 Day_Night 列中分配了 DayNight 4小时是白天还是晚上。

我想将这些数据绘制在背靠背直方图中,其中每个深度箱沿图垂直列出,白天的值绘制在一个面向单向的直方图中,而夜间的值则面向另一种方式。由于我是新手,所以我无法发布图片,但要了解我的意思,请查看 this publication 第 8 页上的图 5。

编辑:这是图片:

感谢您的帮助!

【问题讨论】:

  • 你能提供一些可重现的数据吗?你试过什么了?您遇到的确切问题是什么? stackoverflow.com/questions/5963269/… 通常 SO 问题针对的是详细的细节,而不是“我该怎么做”?您需要帮助我们帮助您!

标签: r plot histogram


【解决方案1】:

您可以使用plotrix 例如:

set.seed (123)
mm <- matrix (sample(seq(0,330,10),2000,rep=TRUE),ncol=2 )
ll <- lapply(as.data.frame(mm),
       function(x)as.data.frame(table(cut(x,seq(0,330,10)))))


library(plotrix)
par(mar=pyramid.plot(ll$V1$Freq,ll$V2$Freq,
                     labels =ll$V1$Var1,
                     top.labels=c("NIGHT","","DAY"),
                     xlim=c(100,100),
                     main="Swimming depth",
                     lxcol="black",rxcol= "white",
                     gap=0,
                     do.first="plot_bg('pink')"))

【讨论】:

  • 这非常接近,但我的问题是绘制我的数据,这些数据位于不等的 bin 中。例如我的数据:结构(列表(Day_Night =结构(c(1L,1L,1L),.Label = c(“白天”,“夜晚”),class=“因子”),0-10 = c(100 , 17.3, 0), 25 = c(0, 0, 0.6), 50 = c(0, 82.2, 83.8), 75 = c(0, 0.6, 12.8), 100 = c (0, 0, 2.8), 125 = c(0, 0, 0), 150 = c(0, 0, 0), 200 = c(0, 0, 0), 250 = c(0L, 0L, 0L), 300 = c(0L, 0L, 0L), 1000 = c(0L, 0L, 0L)), .Names = c("Day_Night", "0-10 "、"25"、"50"、"75"、"100"、"125"、"150"、"200"、"250"、"300"、"1000"),row.names = c(NA , 3L), class= "data.frame")
猜你喜欢
  • 1970-01-01
  • 2018-05-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-05
相关资源
最近更新 更多