【问题标题】:R version3.4.3: Overlapping labels in bar-plot in R (ggplot) [duplicate]R version3.4.3:R(ggplot)中条形图中的重叠标签[重复]
【发布时间】:2017-12-25 15:18:57
【问题描述】:

我正在尝试创建条形图,但由于字符串的长度,标签重叠。我尝试缩短字符串的名称,但这会改变底层顺序。当我手动尝试使用 levels 设置顺序时,我得到了一堆 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

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:
      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))
    

    【讨论】:

      猜你喜欢
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 2015-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多