scale_fill_manual不会在我的facet barplot中添加任何图例

时间:2018-04-05 03:20:46

标签: r

我正在创建一个不同颜色的刻面条形图,代表不同的值范围。我想在图表中添加一个图例来显示范围及其相应的颜色,但scale_fill_manual不起作用。如何纠正这个问题?真的很感谢你的帮助。

代码如下:

public static void main(String[] args) throws IOException {


    QuickTest mfe = new QuickTest();
    ZipFile zip = new ZipFile("test.txt.zip");

    for (Enumeration e = zip.entries(); e.hasMoreElements(); ) {
        ZipEntry entry = (ZipEntry) e.nextElement();
        System.out.println(entry.getName());
        if (!entry.isDirectory()) {
            if (FilenameUtils.getExtension(entry.getName()).equals("txt")) {
                StringBuilder out = getTxtFiles(zip.getInputStream(entry));
                System.out.println(out.toString());
            }
        }
    }


    System.out.println("Done");
}

private  static StringBuilder getTxtFiles(InputStream in)  {
    StringBuilder out = new StringBuilder();
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    String line;
    try {
        while ((line = reader.readLine()) != null) {
            out.append(line);
        }
    } catch (IOException e) {
        // do something, probably not a text file
        e.printStackTrace();
    }
    return out;
}

1 个答案:

答案 0 :(得分:1)

确保fill功能中出现aes。尝试

ggplot(dd,aes(x=t_in_day,y=dd[,y],fill=cuts)) + 
  ...