我正在尝试创建一个条形图但由于字符串的长度标签重叠。我尝试缩短字符串的名称,但这会改变基础顺序。当我手动尝试使用级别设置订单时,我得到了一堆NA。
ggplot(income_educa_copy, aes(x = factor(X_educag), fill = X_incomg))+
geom_bar(position = position_fill(reverse = TRUE)) +
ggtitle("Educational Achievement of Respondents") +
scale_fill_brewer("Income \nLevel",palette="Green",direction=-1) +
xlab("Educational Achievement") +
ylab("Proportion")
以下是图表图片的链接。 Bar Plot Image
答案 0 :(得分:0)
ggplot(income_educa_copy, aes(x = factor(X_educag), fill = X_incomg))+
geom_bar(position = position_fill(reverse = TRUE)) +
ggtitle("Educational Achievement of Respondents") +
scale_fill_brewer("Income \nLevel",palette="Green",direction=-1) +
xlab("Educational Achievement") +
ylab("Proportion") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))