r语言条形图怎样调整counts值
答案:1 悬赏:40 手机版
解决时间 2021-12-02 08:22
- 提问者网友:疯子也有疯子的情调
- 2021-12-01 09:52
r语言条形图怎样调整counts值
最佳答案
- 五星知识达人网友:由着我着迷
- 2021-12-01 10:43
ggplot2包可以用来绘图,其中的geom_text函数可以设置标签:
library(plyr)
library(ggplot2)
library(scales)
dtf <- data.frame(x = c("ETB", "PMA", "PER", "KON", "TRA",
"DDR", "BUM", "MAT", "HED", "EXP"),
y = c(.02, .11, -.01, -.03, -.03, .02, .1, -.01, -.02, 0.06))
ggplot(dtf, aes(x, y)) +
geom_bar(stat = "identity", aes(fill = x)) +
geom_text(aes(label = paste(y * 100, "%"),
vjust = ifelse(y >= 0, 0, 1))) +
scale_y_continuous("Anteil in Prozent", labels = percent_format())
library(plyr)
library(ggplot2)
library(scales)
dtf <- data.frame(x = c("ETB", "PMA", "PER", "KON", "TRA",
"DDR", "BUM", "MAT", "HED", "EXP"),
y = c(.02, .11, -.01, -.03, -.03, .02, .1, -.01, -.02, 0.06))
ggplot(dtf, aes(x, y)) +
geom_bar(stat = "identity", aes(fill = x)) +
geom_text(aes(label = paste(y * 100, "%"),
vjust = ifelse(y >= 0, 0, 1))) +
scale_y_continuous("Anteil in Prozent", labels = percent_format())
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯