ggplot气泡图:多个图例不同的线

时间:2017-10-02 20:58:21

标签: r ggplot2

我有一些数据:

df <- data.frame(grade=c('C','F','D','B','A','C','A','A','C','F','B','B','C','A','B'),test=c(800,700,750,220,550,650,675,350,350,460,780,540,675,490,370),
  condition=c('Condition 2','Condition 2','Condition 1','Condition 1','Condition 1','Condition 2','Condition 1','Condition 2','Condition 2','Condition 2','Condition 1','Condition 2','Condition1','Condition 2','Condition 2'), 
  count=c(10,11,12,15,12,13,15,13,19,18,15,20,20,22,23))

我试图将传说放在底部和中心

example <- ggplot(df, aes(x = grade, y = test, size = count, fill = condition)) +
  geom_point(shape=21)  +
  theme(legend.position = "bottom") + 
  guides(fill = guide_legend(order=1), size = guide_legend(order=2))

enter image description here

如果传说看起来像这样,我会喜欢它: 条件 [条件传奇] 计数 [计数传奇]

我尝试了这个,然后把赤裸的地方放在了错误的地方

example <- ggplot(df, aes(x = grade, y = test, size = count, fill = condition)) +
  geom_point(shape=21)  + 
  theme(legend.position = "bottom", nrow=4) + 
  guides(fill = guide_legend(order=1), size = guide_legend(order=2))

我发现说明here并没有改变(搜索“p2 + theme(legend.position =”bottom“)”

example <- ggplot(df, aes(x = grade, y = test, size = count, fill = condition)) + 
  geom_point(shape=21)  + 
  theme(legend.position = "bottom") + 
  guides(fill = guide_legend(order=1), size = guide_legend(order=2)) + theme(legend.title.align=0.5)+ 
  theme(legend.justification = "bottom")

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

关闭this answer我来到了以下地方:

public class Square {
    private int sideLength;

    public Square(int length) {
        sideLength = length;
    }

    public int getArea() {
        int area = sideLength * sideLength;
        return area;
    }
}

enter image description here