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

时间:2016-09-14 14:07:49

标签: r ggplot2 axis facet

我想将x轴分成两组。我已经设法使用facet创建一个组但不能再制作第二个组。这是我已经拥有的和我想要的东西的图片。 这也是我的命令:

var button = (Button)sender;
var row = Grid.GetRow(button);
var grid = button.Parent as Grid;
//assuming the image is in column 1
var image = grid.Children.Where(c => Grid.GetRow(c) == row && Grid.GetColumn(c)==1);

Chart

示例Data.csv:

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)")

1 个答案:

答案 0 :(得分:0)

感谢您的评论。 aosmith:完美的作品。我现在唯一的问题是排序错误。我想从P1,P2,...... P12开始 这就是我现在所拥有的:

almost