相关疑难解决方法(0)

ggplot2馅饼和甜甜圈图表在同一个地块上

我想复制这个 在此输入图像描述与R ggplot.我有完全相同的数据:

browsers<-structure(list(browser = structure(c(3L, 3L, 3L, 3L, 2L, 2L, 
2L, 1L, 5L, 5L, 4L), .Label = c("Chrome", "Firefox", "MSIE", 
"Opera", "Safari"), class = "factor"), version = structure(c(5L, 
6L, 7L, 8L, 2L, 3L, 4L, 1L, 10L, 11L, 9L), .Label = c("Chrome 10.0", 
"Firefox 3.5", "Firefox 3.6", "Firefox 4.0", "MSIE 6.0", "MSIE 7.0", 
"MSIE 8.0", "MSIE 9.0", "Opera 11.x", "Safari 4.0", "Safari 5.0"
), class = "factor"), share = c(10.85, 7.35, 33.06, 2.81, 1.58, 
13.12, 5.43, 9.91, 1.42, 4.55, 1.65), …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 pie-chart donut-chart

30
推荐指数
5
解决办法
2万
查看次数

如何将标签放在饼图之外?

如何将标签放在饼图外面以便标签放在适当的位置?

Product <- c("Product1","Product2","Product3","Product4","Product5","Product6","Product7")
Value <- c(1000000,200002,599996,1399994,2199992,2999990,3799988)
df <- data.frame(Product,Value)
df$Label <- paste(Product, paste(round(((df$Value/sum(df$Value))*100),2),"%"), sep="-")

library(ggplot2)

p <-  ggplot(df, aes(x = 1, y = Value, fill = Product)) + geom_bar(stat = "identity")
p <- p + coord_polar(theta = 'y') + theme_void()
p <- p + geom_text(aes(label = Label), position = position_stack(vjust = 0.5))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

r ggplot2 pie-chart

6
推荐指数
1
解决办法
4905
查看次数

标签 统计

ggplot2 ×2

pie-chart ×2

r ×2

donut-chart ×1