在这里您可以看到我的代码的一部分。
ratiox = seq(0, 3, 0.05)
x = rnorm(61, 55000, 3)
y1 = rep(200, times = 61)
l = cbind(ratiox, x, y1)
l = as.data.frame(l)
l$y1 = as.character(l$y1)
y1 = rep(100, times = 61)
m = cbind(ratiox, x, y1)
m = as.data.frame(m)
m$y1 = as.character(m$y1)
y1 = rep(50, times = 61)
n = cbind(ratiox, x, y1)
n = as.data.frame(n)
n$y1 = as.character(n$y1)
y1 = rep(25, times = 61)
o = cbind(ratiox, x, y1)
o = as.data.frame(o)
o$y1 = as.character(o$y1)
total = rbind(l,m,n,o)
View(total)
ggplot(total, aes(x = ratiox, y = y1, height = x/100000, fill = y1)) +
geom_ridgeline() + scale_fill_manual(values = c("green", "gray", "lightblue", "red", "blue", "black")) + xlab("Emission ratio") +
ylab("") + theme_classic(base_size = 25)
最后,这些图的顺序不符合我的期望。我希望各种浓度(y1)的顺序与输入的顺序相对应。含义:200、100、50和25。我希望变量y1保持字符。我不想将其转换为数字变量。
答案 0 :(得分:0)
将您的y1
变量转换为一个因子,并根据需要对水平进行排序。
total$y1 <- factor(total$y1, levels = c("200", "100", "50", "25"))