为饼图添加百分比 (%)
Add percentage (%) for a PieChart
大家好,我正在尝试制作如下图所示的饼图:
但是我遇到了很多问题
但这是我得到的情节:
ggpie(s, x="costes", label ="prop", lab.pos = "in", fill = "Implementation",
lab.font = list(size= 5)) + scale_fill_manual(values = c("dodgerblue2","blue"))
我如何将百分比添加到我的标签中,例如 98.9%...等等
数据:
structure(list(Implementation = c("2", "1"), costes = c(6204670582.33, 70561379.07), prop = c(98.9, 1.1), lab.ypos = c(49.45, 99.45)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"))
非常感谢您的宝贵时间
您可以添加'labels = '。我将你的数据命名为虚拟。
> dummy
# A tibble: 2 x 4
Implementation costes prop lab.ypos
<chr> <dbl> <dbl> <dbl>
1 2 6204670582. 98.9 49.4
2 1 70561379. 1.1 99.4
dummy %>%
ggpie(x="costes", label ="prop", lab.pos = "in", fill = "Implementation",
lab.font = list(size= 5)) +
scale_fill_manual(values = c("dodgerblue2","blue"),
labels = paste(dummy$Implementation, (dummy$prop)))
per <- c(0.1,0.2,0.3,0.4)
labels <- c("a","b","c","d")
pie(per,labels = paste0(labels," (",round(per,digits = 3)*100,"%)"),
border="white",col = c("red","green","blue","yellow"))
大家好,我正在尝试制作如下图所示的饼图: 但是我遇到了很多问题
但这是我得到的情节:
ggpie(s, x="costes", label ="prop", lab.pos = "in", fill = "Implementation",
lab.font = list(size= 5)) + scale_fill_manual(values = c("dodgerblue2","blue"))
我如何将百分比添加到我的标签中,例如 98.9%...等等
数据:
structure(list(Implementation = c("2", "1"), costes = c(6204670582.33, 70561379.07), prop = c(98.9, 1.1), lab.ypos = c(49.45, 99.45)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"))
非常感谢您的宝贵时间
您可以添加'labels = '。我将你的数据命名为虚拟。
> dummy
# A tibble: 2 x 4
Implementation costes prop lab.ypos
<chr> <dbl> <dbl> <dbl>
1 2 6204670582. 98.9 49.4
2 1 70561379. 1.1 99.4
dummy %>%
ggpie(x="costes", label ="prop", lab.pos = "in", fill = "Implementation",
lab.font = list(size= 5)) +
scale_fill_manual(values = c("dodgerblue2","blue"),
labels = paste(dummy$Implementation, (dummy$prop)))
per <- c(0.1,0.2,0.3,0.4)
labels <- c("a","b","c","d")
pie(per,labels = paste0(labels," (",round(per,digits = 3)*100,"%)"),
border="white",col = c("red","green","blue","yellow"))