R、 一个图中的两层直方图 seed\u ant
这里,我希望这能帮到你R、 一个图中的两层直方图 seed\u ant,r,histogram,R,Histogram,这里,我希望这能帮到你 seed_ant <- read.table(...) thatch_ant <- read.table(...) seed_mass <- seed_ant$Mass seed_mass[578:1195] <- 0 thatch_mass <- thatch_ant$Mass combined <- cbind(seed_mass, thatch_mass) combined_mass <- data.frame(combin
seed_ant <- read.table(...)
thatch_ant <- read.table(...)
seed_mass <- seed_ant$Mass
seed_mass[578:1195] <- 0
thatch_mass <- thatch_ant$Mass
combined <- cbind(seed_mass, thatch_mass)
combined_mass <- data.frame(combined)
ggplot(combined_mass, aes(x=combined, ylilm=c(0,350))) +
geom_histogram(alpha=0.2, position="identity")
A删除ylilm=c(0350)
时会发生什么?另外,我不确定这一个组合质量,你不能通过将向量的值设置为0
来缩短向量。尝试seed\u mass我只是不知道怎么写'dat',所以我只是做了一个组合质量的数据框,我知道这是错误的,我应该怎么写dat和x=?我没有缩短它们,我只是想让发送质量的长度等于thatch\u mass,你可以让data=Null。类似于ggplot(,aes(x=…)
我真的很抱歉打扰你,我能再问你一个问题吗?当然。任何能帮上忙的人都会喜欢做那件事的。更正,去掉那些零。最简单的方法是colB-thx这么多。。。我真的很感谢你的帮助,我为此奋斗了两天
A <- rnorm(1000) # this is seed_mass
B <- rexp(1000) # this is thatch_mass
colB <- rep(LETTERS[1:2], each = 1000) # this is to tell them apart
colA <- c(A,B) # combine them together
dt <- data.frame(colA, colB) # create Data frame
ggplot(dt, aes(x = colA, fill = colB)) +
geom_histogram(col = "black", alpha = 0.5,
position = "identity") +
scale_fill_discrete(name = "your title",
breaks=c("A", "B"),
labels = c("1","2")) # plot