This is how it looks right now
I have this code in R, but it makes a "donut" however I want to create half a donut. With the information at the top with 85% in dark blue and 15% in light blue with a red line at 37%. But whatever I do I cannot get ride of the blue part on the left side of the black line.
Moreover, it would be totally perfect if there where text labels also mentioning the 85%,15% and 37 %
People are Saying I need to switch back to Excel but I want to proof it is possible in R too ;)
# Verwijder alle vorige objecten
rm(list = ls())
library(ggplot2)
# Dummy data voor de chart
data <- data.frame(
categorie = c("Categorie 1", "Categorie 2"),
waarde = c(0.85, 0.15)
)
# Kleuren per deel
kleuren <- c("#468bcc", '#cae6f2') # donker en lichtblauw
# Pijl locatie
arrow = 0.37
# Berekeningen voor de halve cirkel
total <- sum(data$waarde)
data$percentage <- data$waarde / total
data$start <- cumsum(data$percentage) - data$percentage
data$einde <- cumsum(data$percentage)
# Maak de plot
plot <- ggplot(data, aes(x = 1, y = waarde, fill = categorie)) +
geom_rect(aes(xmin = 1, xmax = 2, ymin = start, ymax = einde * 2), color = NA) +
geom_segment(aes(x = 1, y = arrow, xend = 2, yend = arrow), color = "red", size = 1) +
coord_polar(theta = "y", start = 0) + # Draai de figuur niet
xlim(0.5, 2.5) +
theme_void() +
theme(legend.position = "none")
# Voeg zwarte lijnen toe bij 0 en 100 graden
plot <- plot +
geom_segment(aes(x = 1, y = 0, xend = 2, yend = 0), color = "black", size = 1) +
geom_segment(aes(x = 1, y = 1, xend = 2, yend = 1), color = "black", size = 1)
# Pas de kleuren van de delen aan
plot <- plot + scale_fill_manual(values = kleuren)
# Plot de halve cirkel donut chart
print(plot)
Not sure this is what you want. This is done with the rAmCharts4 package.
library(rAmCharts4)
gradingData <- data.frame(
label = c("Bottom", "Top"),
color = c("lightblue", "darkblue"),
lowScore = c(0, 15),
highScore = c(15, 100)
)
amGaugeChart(
score = 37, minScore = 0, maxScore = 100, gradingData = gradingData,
hand = amHand(innerRadius = 40, width = 15, color = "red", strokeColor = "black")
)
You can replace "bottom" and "top" by the percentages.