首页 > 其他分享 >ggplot2绘制饼图

ggplot2绘制饼图

时间:2023-02-11 09:11:06浏览次数:38  
标签:绘制 library data 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()

  

标签:绘制,library,data,ggplot2,数据,加载
From: https://www.cnblogs.com/biohujun/p/17110861.html

相关文章