小编Jea*_*lur的帖子

将标签添加到百分比堆叠条形图 ggplot2

我是 ggplot 新手,希望为我正在为其进行可视化的数据集获得一些帮助。

这是我当前的代码:

#create plot
plot <- ggplot(newDoto, aes(y = pid3lean, weight = weight, fill = factor(Q29_1String, levels = c("Strongly disagree","Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree")))) + geom_bar(position = "fill", width = .732) 
#fix colors
plot <- plot + scale_fill_manual(values = c("Strongly disagree" = "#7D0000", "Somewhat disagree" = "#D70000","Neither agree nor disagree" = "#C0BEB8", "Somewhat agree" = "#008DCA", "Strongly agree" = "#00405B")) 
#fix grid
plot <- plot + guides(fill=guide_legend(title="29")) + theme_bw() + theme(panel.grid.major = element_blank(), …
Run Code Online (Sandbox Code Playgroud)

plot r bar-chart ggplot2 dataframe

5
推荐指数
1
解决办法
5671
查看次数

标签 统计

bar-chart ×1

dataframe ×1

ggplot2 ×1

plot ×1

r ×1