Reputation: 197
I want to make a pie chart without any labels, but with a title.
However, I do not manage to combine both requirements: or I have a pie chart without a title and without axis (left picture), or I have a pie chart with a title and axis (right picture). See the picture below:
Is it possible to add a title to the left picture, or remove the axis on the right picture?
data<-structure(list(nuts0 = c("IT", "IT", "IT", "IT", "IT", "IT",
"IT", "IT", "IT", "IT"), variable = structure(1:10, .Label = c("percentage_irri10",
"percentage_irri20", "percentage_irri30", "percentage_irri40",
"percentage_irri50", "percentage_irri60", "percentage_irri70",
"percentage_irri80", "percentage_irri90", "percentage_irri100"
), class = "factor"), value = c(0.100915431560593, 0.0860941586748038,
0.0695292066259808, 0.0662598081952921, 0.0745422842197036, 0.0512205754141238,
0.0599389712292938, 0.047079337401918, 0.0551438535309503, 0.389276373147341
)), .Names = c("nuts0", "variable", "value"), row.names = c(10L,
25L, 40L, 55L, 70L, 85L, 100L, 115L, 130L, 145L), class = "data.frame")
percentlabelsIT<- round(100*data$value, 0)
pielabelsIT<- paste(percentlabelsIT, "%", sep="")
cols <- c("yellow","greenyellow","#00FF00", "#00C639","#00AA55", "#00718E", "#0055AA", "#001CE3","blue4","midnightblue")
pie <- ggplot(data, aes(x = factor(1), fill = factor(percentlabelsIT))) + geom_bar(width = 1)+
ggtitle("help")+
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank(),
legend.position="none",
line = element_blank(),
text = element_blank()
)+
scale_fill_manual(values=cols)
l1<-pie + coord_polar(theta = "y")
l1
Upvotes: 1
Views: 5104
Reputation: 3162
Try this (without text=
but with axis.title
and ggtitle
):
pie <- ggplot(data, aes(x = factor(1), fill = factor(percentlabelsIT))) + geom_bar(width = 1)+
ggtitle("help")+
theme(axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank(),
legend.position="none",
line = element_blank()
)+
scale_fill_manual(values=cols)
l1 <-pie + coord_polar(theta = "y") + ggtitle("kdfja")
l1
Upvotes: 1