Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hole in Bullseye in ggplot2

Tags:

r

ggplot2

I have prepared bullseye chart using ggplot. But I get a hole. How to remove it and get whole one?

enter image description here

critters <- structure(list( a = 15, b = 47, c = 22, d=9, e=7), .Names = c("a", "b", "c", "d", "e"), row.names = c(NA, -1L), class = "data.frame")

d <- data.frame(test=factor(c(rep("a", critters$a),
                            rep("b", critters$b), 
                            rep("c", critters$c),
                            rep("d", critters$d),
                            rep("e", critters$e)),
                          levels = c("a", "b", "c", "d", "e"), ordered= TRUE))
levels(d$test) <- apply(data.frame(table(d$test)), 1, paste, collapse = ": ")

ggplot(d, aes(x = factor(1), fill = factor(test))) + geom_bar()+ coord_polar() + labs(x = NULL, fill = NULL) + scale_fill_manual(values = c("blue", "yellow", "green", "red", "magenta"))
like image 829
Agnieszka Avatar asked May 17 '16 10:05

Agnieszka


1 Answers

You need to set width = 1 in geom_bar.

ggplot(d, aes(x = factor(1), fill = factor(test))) +
  geom_bar(width = 1) +
  coord_polar() +
  labs(x = NULL, fill = NULL) +
  scale_fill_manual(values = c("blue", "yellow", "green", "red", "magenta"))
like image 114
Mhairi McNeill Avatar answered Sep 20 '22 00:09

Mhairi McNeill