rggplot2scatterpie

Scale scatterpie plots ggplot


I have this data

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


 

I am trying to do some scatterpie plots, but I don't get the pies correctly. I used this:

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)

And I got this:

pies

Everytime I change the r, the pies only become thinner. And If I leave the r = TotalOvershootings, I get the big pies overlapping.

What can I change so I get the pies well? I want to see round piecharts and not ovals every time that I change the r.


Solution

  • Apparently you only need to use 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()
    

    enter image description here