R ggplot2垂直剖面图
我正试图用标准偏差阴影绘制垂直剖面图。我使用我通常用于timeseries绘图的命令行,但它在垂直剖面中工作错误R ggplot2垂直剖面图,r,ggplot2,R,Ggplot2,我正试图用标准偏差阴影绘制垂直剖面图。我使用我通常用于timeseries绘图的命令行,但它在垂直剖面中工作错误 ggplot(data = df_join2, aes(x = mean, y = plm, color = variable)) + geom_line(aes(x = mean, color = variable), size = 2) + scale_colour_manual(name = varnm, values = clr2) +
ggplot(data = df_join2, aes(x = mean, y = plm, color = variable)) +
geom_line(aes(x = mean, color = variable), size = 2) +
scale_colour_manual(name = varnm, values = clr2) +
geom_ribbon(aes(x = mean, xmin = mean - sd, xmax = mean + sd, fill = variable), alpha = .3, show.legend = FALSE) +
scale_fill_manual(name = varnm, values = clr2) +
scale_y_continuous(trans = "reverse", breaks = c(1000,750,500,250,100)) +
xlab(nm2) + ylab("Pressure (mb)") + theme_bw() + theme(legend.key = element_blank()) +
guides(color = guide_legend(override.aes = list(linetype = c(1), shape = c(NA)))) + #theme(plot.margin=unit(c(1,3,1,1),"cm"))+
theme(legend.position = "none")
我使用的数据是:
plm variable mean sd
1 99.0 hum 1.441467e-08 2.255813e-08
2 118.0 hum 1.274516e-08 2.816413e-08
3 139.0 hum 1.871454e-08 4.622236e-08
4 161.5 hum 2.545867e-08 8.023293e-08
5 185.0 hum 1.390923e-08 1.114903e-07
6 210.0 hum 1.152322e-07 1.153853e-07
7 237.0 hum 2.782828e-07 1.350924e-07
8 266.5 hum 4.848867e-07 1.995094e-07
9 299.0 hum 8.357763e-07 3.158922e-07
10 335.0 hum 1.397717e-06 5.110624e-07
11 375.0 hum 2.135646e-06 8.599465e-07
12 418.5 hum 3.393004e-06 1.359676e-06
13 465.0 hum 5.635352e-06 2.032474e-06
14 514.0 hum 7.140172e-06 2.816654e-06
15 565.0 hum 1.009809e-05 3.730973e-06
16 616.5 hum 1.309488e-05 4.803978e-06
17 667.0 hum 1.679745e-05 5.979570e-06
18 716.0 hum 1.859773e-05 7.257538e-06
19 762.5 hum 2.126635e-05 8.653999e-06
20 805.0 hum 2.098323e-05 9.801954e-06
21 842.5 hum 2.433523e-05 1.100483e-05
22 875.0 hum 2.289352e-05 1.181187e-05
23 903.5 hum 2.477932e-05 1.241182e-05
24 929.5 hum 2.357829e-05 1.299938e-05
25 953.0 hum 2.027214e-05 1.278464e-05
26 974.0 hum 1.948147e-05 1.705238e-05
有什么建议吗?
谢谢试试这个方法。在
geom\u行中添加orientation=“y”
。
(我对出现clr2
和nm2
的地方发表了评论,因为我不知道它们)
试试这种方法。在geom\u行中添加orientation=“y”
。
(我对出现clr2
和nm2
的地方发表了评论,因为我不知道它们)
你能补充一下clr2
是如何定义的吗?我试着用它的时候,它看起来很不错。。怎么了?@Edo clr2就是这个颜色。。你可以不用它来运行它是的,我知道,我想帮助他制作一个完全可复制的示例。你能添加一下clr2
是如何定义的吗?当我尝试它时,它看起来相当不错。。怎么了?@Edo clr2就是这个颜色。。你可以不用它运行它是的,我知道,我想帮助他制作一个完全可复制的例子。谢谢,效果很好:)谢谢,效果很好:)
library(ggplot2)
ggplot(data = df_join2, aes(x = mean, y = plm, color = variable)) +
geom_line(aes(color = variable), size = 2, orientation = "y") +
# scale_colour_manual(name = varnm, values = clr2) +
geom_ribbon(aes(x = mean, xmin = mean - sd, xmax = mean + sd, fill = variable), alpha = .3, show.legend = FALSE) +
# scale_fill_manual(name = varnm, values = clr2) +
scale_y_continuous(trans = "reverse", breaks = c(1000,750,500,250,100)) +
# xlab(nm2) +
ylab("Pressure (mb)") +
theme_bw() +
theme(legend.key = element_blank()) +
guides(color = guide_legend(override.aes = list(linetype = c(1), shape = c(NA)))) + #theme(plot.margin=unit(c(1,3,1,1),"cm"))+
theme(legend.position = "none")