1

我有这个数据

structure(list(year = c("2018", "2018", "2018", "2018", "2018", 
"2018", "2018", "2018", "2018", "2018", "2018", "2018"), month = c(1, 
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), Avdischarge = c(906.5947917, 
511.2469444, 364.0697222, 268.3026389, 141.5931944, 142.0445486, 
37.53111111, 34.68916667, 35.50809028, 26.94083333, 40.400381945, 
312.0436806), IndustrialCompound = c(0.729166666666667, 0.815789473684211, 
0.818181818181818, 0.771428571428571, 0.736842105263158, 0.761904761904762, 
0.780487804878049, 0.829268292682927, 0.8, 0.780487804878049, 
0.738095238095238, 0.731707317073171), Pharmaceutical = c(0.145833333333333, 
0.105263157894737, 0.113636363636364, 0.142857142857143, 0.131578947368421, 
0.119047619047619, 0.121951219512195, 0.0975609756097561, 0.114285714285714, 
0.146341463414634, 0.166666666666667, 0.195121951219512), Pesticide = c(0.125, 
0.0789473684210526, 0.0681818181818182, 0.0857142857142857, 0.131578947368421, 
0.119047619047619, 0.0975609756097561, 0.0731707317073171, 0.0857142857142857, 
0.0731707317073171, 0.0952380952380952, 0.0731707317073171), 
    TotalOvershootings = c(0.48, 0.558823529411765, 0.619718309859155, 
    0.538461538461538, 0.612903225806452, 0.591549295774648, 
    0.561643835616438, 0.554054054054054, 0.538461538461538, 
    0.577464788732394, 0.617647058823529, 0.694915254237288)), row.names = 37:48, class = "data.frame")


 

我正在尝试做一些散点图,但我没有正确地得到馅饼。我用这个:

pie<-ggplot()+geom_scatterpie(aes(x=month, y=2, group=type, r = TotalOvershootings/5), 
                                        cols= c("IndustrialCompound", "Pharmaceutical", "Pesticide"),alpha= 0.7, color=NA,
                                        data= counts)

我得到了这个:

馅饼

每次我改变 r,馅饼只会变薄。如果我离开r = TotalOvershootings,我会让大馅饼重叠。

我能做些什么改变才能把馅饼做好?每次更改 r 时,我都希望看到圆形饼图而不是椭圆形。

4

1 回答 1

2

显然你只需要使用coord_fixed()

ggplot()+
geom_scatterpie(aes(x=month, y=2, r=TotalOvershootings/1.35),
                cols= c("IndustrialCompound", "Pharmaceutical", "Pesticide"), 
                alpha= 0.7, color=NA, data= counts)+
coord_fixed()

在此处输入图像描述

于 2019-05-07T11:33:54.177 回答