简体   繁体   English

R中的ggplot - 将x轴分成两组

[英]ggplot in R - divide x axis in two groups

I would like to divide my x axis into two groups. 我想将x轴分成两组。 I managed already to make one group using facet but can't make a second one. 我已经设法使用facet创建一个组但不能再制作第二个组。 Here is a picture of what I already have and what I want additionally. 这是我已经拥有的和我想要的东西的图片。 Here is also my command: 这也是我的命令:

ggplot(myk.p, aes(x=Group, y=Colonization, fill=MO)) +
    geom_bar(stat="identity", colour="black") +
    scale_fill_manual(values=c("#000000","#7a7a7a","#c0c0c0")) +
    theme(panel.margin = unit(0, "lines"), strip.background =
    element_blank()) + facet_wrap(~Water, switch = "x", scales = "free_x") +
    ggtitle("Root mycorrhization in % (Populus nigra)")

图表

Example Data.csv: 示例Data.csv:

"Group" "Colonization"  "MO"    "Water" "Fertilizer"
"P1"    69,2307692308   "C" "once"  "without"
"P2"    71,8232044199   "F" "once"  "without"
"P3"    82,5174825175   "I" "once"  "without"
"P4"    66,4122137405   "C" "once"  "with"
"P5"    86,013986014    "F" "once"  "with"
"P6"    98,7654320988   "I" "once"  "with"
"P7"    41,9540229885   "C" "twice" "without"
"P8"    65,7894736842   "F" "twice" "without"
"P9"    63,9705882353   "I" "twice" "without"
"P10"   62,5850340136   "C" "twice" "with"
"P11"   87,012987013    "F" "twice" "with"
"P12"   89,696969697    "I" "twice" "with"

Thanks for the comments. 感谢您的评论。 aosmith: Works perfect. aosmith:完美的作品。 The only problem I now have is that the ordering is wrong. 我现在唯一的问题是排序错误。 I want to start it from P1,P2,...P12 This is what I got now: 我想从P1,P2开始...... P12这就是我现在得到的:

almost 几乎

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM