【发布时间】:2020-07-29 21:04:03
【问题描述】:
我正在尝试根据一系列 glmm 输出的置信区间制作卡特彼勒图。 因此,我制作了一个简单的表(tabla),其中包含索引名称(8)、参数(每个索引 3 个)和间隔(每个参数 2 个值 = min_value - max_value)。我希望我的绘图按索引和 Y 轴上每个索引的 3 个参数进行分组。
我尝试使用 ggplot,但我的知识不足让我无法继续。
我的代码:
library(ggplot2)
read.csv("ggplot_modelos.csv", header = TRUE, sep = ";", dec = ".")-> tabla
View(tabla)
names(tabla)
ggplot(tabla, aes(Intervalls, Index) , geom_bar(aes(Intervals, Parameter)))
我的数据:
tabla <-
data.frame(
stringsAsFactors = FALSE,
Index = c("H","H","H","H","H","H",
"ADI","ADI","ADI","ADI","ADI","ADI","AEI","AEI",
"AEI","AEI","AEI","AEI","BIO","BIO","BIO","BIO",
"BIO","BIO","ACI","ACI","ACI","ACI","ACI","ACI","M",
"M","M","M","M","M","Ht","Ht","Ht","Ht","Ht",
"Ht","AR","AR","AR","AR","AR","AR"),
Parameter = c("Intercept","Intercept",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance","Intercept","Intercept",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance","(Intercept)","(Intercept)",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance","(Intercept)","(Intercept)",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance","(Intercept)","(Intercept)",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance","(Intercept)","(Intercept)",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance","(Intercept)","(Intercept)",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance","(Intercept)","(Intercept)",
"Species Richness","Species Richness","Relative Abundance",
"Relative Abundance"),
Intervalls = c(-0.63399094,0.10088021,
0.05111166,0.11374545,0.01356644,0.03568559,-0.63399094,
0.10088021,0.05111166,0.11374545,0.01356644,0.03568559,
-0.08921982,0.69843374,-0.11735036,-0.05706148,
-0.03492262,-0.01363224,-0.387777431,0.8894038,-0.01656506,
0.04067182,-0.004208021,0.01583599,-1.42348399,
0.78640078,0.13746715,0.21376064,0.06880861,0.09518447,
-0.44656228,0.46793251,0.03039887,0.05458163,
0.05991785,0.12952663,-0.384061,1.50738256,-0.2298068,
-0.1467239,-0.106336,-0.07786533,-0.54823458,1.23599168,
-0.04350877,-0.01813159,-0.09811032,-0.02568451)
)
如果有人能帮我一下,我将不胜感激!
【问题讨论】:
-
通常首先是
ggplot(data, aes(x, y))(注意括号关闭),然后添加(+)每个组件/层/主题元素,例如您的geom_bar。过于简化,通常看起来像ggplot(...,aes(...)) + geom_bar(...)。 -
也许这会有所帮助:stackoverflow.com/questions/34344599/…。你确定要
geom_bar?