相关疑难解决方法(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万
查看次数

ggplot饼图标签

我正在努力让饼图标签正确.环顾四周,并认为我可以轻松实现mathCoffee的功能.到目前为止,我有这个代码:

ltr = LETTERS[seq( from = 1, to = 26)]

wght = runif(length(ltr))
wght = wght/sum(wght)
wght = round(wght, digits = 2)

alloc = as.data.frame(cbind(ltr, wght))
alloc$wght = as.numeric(as.character(alloc$wght))

ggpie <- function (dat, by, totals) {
  ggplot(dat, aes_string(x=factor(1), y=totals, fill=by)) +
    geom_bar(stat='identity', color='black') +
    guides(fill=guide_legend(override.aes=list(colour=NA))) +
    coord_polar(theta='y') +
    theme(axis.ticks=element_blank(),
          axis.text.y=element_blank(),
          axis.text.x=element_text(colour='black'),
          axis.title=element_blank()) +
    ## scale_fill_brewer(palette = "GnBu") +
    scale_y_continuous(breaks=cumsum(dat[[totals]]) - dat[[totals]] / 2, labels=paste(dat[[by]], ":", dat[[totals]]))    
}

AA = ggpie(alloc, by = "ltr", totals = "wght") +
  ggtitle("Letter …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 pie-chart

4
推荐指数
2
解决办法
8454
查看次数

标签 统计

ggplot2 ×2

pie-chart ×2

r ×2

donut-chart ×1