erocoar / ggpol

🌍 Parliament diagrams and more for ggplot2

Home Page:https://erocoar.github.io/ggpol/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solid fills

jesbrz opened this issue · comments

Would something like this possible? solid fills instead of points?

52942542-78a35c80-336b-11e9-9091-d470ab1056de

Certainly - although I think it is already implemented via geom_arcbar(). Let me know if this is what you were looking for!

Sorry for delay in reply. Yes, it's a nearly perfect approach. I change sep value to 0.01 to remove the white between. Now I just have to find a way to reduce the thickness of the black lines. Thanks for your help.

I realized thanks to your post that I should account for the possibility of sep = 0. I will fix that ASAP. The thickness of the black lines can (theoretically) be reduced with lwd (since geom_arcbar calls geom_polygon). But there is a minimum width. If you want no black contours at all, you can set color = NA. Below is the adjusted example code:

bt <- data.frame(
  parties = factor(c("CDU", "CSU", "AfD", "FDP", "SPD", 
                     "Linke", "Gruene", "Fraktionslos"),
                   levels = c("CDU", "CSU", "AfD", "FDP", "SPD", 
                              "Linke", "Gruene", "Fraktionslos")),
  seats   = c(200, 46, 92, 80, 153, 69, 67, 2),
  colors  = c("black", "blue", "lightblue", "yellow", "red",
              "purple", "green", "grey"),
  stringsAsFactors = FALSE)

ggplot(bt) + 
  geom_arcbar(aes(shares = seats, r0 = 5, r1 = 10, fill = parties), color = NA, sep = 0.01) + 
  scale_fill_manual(values = bt$colors) +
  coord_fixed() +
  theme_void()

The bug when setting sep = 0 is fixed now, and the updated version will be on CRAN shortly.

image

works like a charm Frederik, thanks a lot! Also color=NA works fine for me.

Glad it helped!