ggplot2绘制饼图
# 加载 ggplot2 包 library(ggplot2) # 加载数据 data <- data.frame(category = c("A", "B", "C", "D"), value = c(10, 20, 30, 40)) # 绘制饼图 ggplot(data, aes(x = "", y = value, fill = category)) + geom_bar(width = 1, stat = "identity") + coord_polar("y", start = 0) + theme_void()