R + ggplot2 => add labels on facet pie chart [duplicate]

I would approach this by defining another variable (which I call pos) in df that calculates the position of text labels. I do this with dplyr but you could also use other methods of course. library(dplyr) library(ggplot2) df <- df %>% group_by(year) %>% mutate(pos = cumsum(quantity)- quantity/2) ggplot(data=df, aes(x=factor(1), y=quantity, fill=factor(prod))) + geom_bar(stat=”identity”) + geom_text(aes(x= … Read more

Percent pie chart with css only

New answer 2021 With some modern techniques we can improve the code. You can have rounded edges and also consider animation: @property –p{ syntax: ‘<number>’; inherits: true; initial-value: 1; } .pie { –p:20; /* the percentage */ –b:22px; /* the thickness */ –c:darkred; /* the color */ –w:150px; /* the size*/ width:var(–w); aspect-ratio:1/1; position:relative; display:inline-grid; … Read more

CSS Only Pie Chart – How to add spacing/padding between slices?

First I would recreate this with less of code relying on clip-path like below: .palette { height: 200px; width: 200px; position:relative; overflow:hidden; } .palette > * { position:absolute; top:0; left:0; right:0; bottom:0; border:50px solid var(–c,red); border-radius:50%; clip-path:polygon(50% 50%, 50% 0%, 100% 0%,100% 33.745%); } .color1 { transform:rotate(72deg); –c:blue; } .color2 { transform:rotate(144deg); –c:orange; } .color3 … Read more

positioning pie slice problems

Because I really don’t understand Turbo C++ I can’t say for sure. But I think this is your solution: void Circular_arc(constint h, constint k, constint r, constint start_angle, constint end_angle) { static int offset = 0; start_angle = (start_angle + offset) % 360; end_angle = (end_angle + offset) % 360; offset = end_angle; int color … Read more