R中的ggplot2情节问题

时间:2016-11-01 19:22:22

标签: r ggplot2

我创建了一个ggplot2图,在那里我讨论了两件事。

1)如何改变颜色?

2)为什么第9项和第10项之间缺少这条线?

@Test
    public void testEndtoEnd() throws Exception {
        TupleTag<Entity> tag1 = aTagFromElsewhere1;
        TupleTag<Entity> tag2 = aTagFromElsewhere2;
        TupleTagList tags = TupleTagList.of(tag1).and(tag2);
        CoGbkResultSchema schema = new CoGbkResultSchema(tags);

        JoinEntities myDoFn = new JoinEntities();
        DoFnTester<KV<String, CoGbkResult>, Entity> fnTester = DoFnTester.of(myDoFn);     
        List<RawUnionValue> rawUnionValues = new ArrayList<RawUnionValue>();
        Date validThruDate = new Date(System.currentTimeMillis() + 5000L);
        rawUnionValues.add(new RawUnionValue(0, aValidEntity1)));
        rawUnionValues.add(new RawUnionValue(1, aValidEntity2));
        CoGbkResult result = new CoGbkResult(schema, rawUnionValues);

        KV<String, CoGbkResult> aCoGbkPair = KV.of("Bleh", result);

        Pipeline p = TestPipeline.create();

        PCollection<KV<String, CoGbkResult>> input = p.apply(Create.of(aCoGbkPair))
                .setCoder(KvCoder.of(StringUtf8Coder.of(), CoGbkResultCoder.of(UnionCoder, schema)));

        PCollection<String> output = input.apply(new FormatEntitiesForTsv());

        DataflowAssert.that(output).containsInAnyOrder(/**TODO: Create test data**/);
    }

screenshot

1 个答案:

答案 0 :(得分:1)

工作示例:

ggplot(data2, aes(x=num, y=cent, colour=groups2)) + 
   geom_line(color='#666666', size=0.7) +
   geom_point() +
   ylab('Strength Centrality') + xlab ('Symptoms') + 
   scale_x_continuous(breaks = c(20:1)) +
   coord_flip() +
   theme_bw() + scale_color_manual(values=c("cyan","green"))+
   theme(panel.grid.minor.y = element_blank())

注意scale_color_manual(values=c(...))主题部分fill以及aes参数的缺失。

enter image description here

请注意,如果您想要撤消订购,您需要执行类似的操作 scale_x_reverse(breaks=c(1:20))因为scale_x_...选项互相覆盖,只有最新实现。