为什么ggplot会这样打印?

时间:2016-03-14 09:46:44

标签: r ggplot2 bar-chart

我有一个数据集

thin50 <- structure(list(yta = c(1102L, 1102L, 1102L, 1102L, 1102L, 1102L, 
    1103L, 1103L, 1103L, 1103L, 1105L, 1105L, 1105L, 1105L, 1105L, 
    1105L, 1107L, 1107L, 1107L, 1107L, 1107L, 1107L, 1108L, 1108L, 
    1108L, 1108L, 1108L, 1108L, 1109L, 1109L, 1109L, 1109L, 1110L, 
    1110L, 1110L, 1110L, 1110L, 1110L, 1113L, 1113L, 1113L, 1113L
    ), avd = c(1L, 1L, 6L, 6L, 7L, 7L, 2L, 2L, 5L, 5L, 2L, 2L, 3L, 
    3L, 5L, 5L, 2L, 2L, 3L, 3L, 7L, 7L, 1L, 1L, 3L, 3L, 4L, 4L, 1L, 
    1L, 2L, 2L, 2L, 2L, 5L, 5L, 6L, 6L, 2L, 2L, 3L, 3L), beh = c("UN", 
    "UN", "50%", "50%", "50%", "50%", "50%", "50%", "UN", "UN", "50%", 
    "50%", "50%", "50%", "UN", "UN", "50%", "50%", "UN", "UN", "50%", 
    "50%", "UN", "UN", "50%", "50%", "UN", "UN", "50%", "50%", "UN", 
    "UN", "50%", "50%", "50%", "50%", "UN", "UN", "UN", "UN", "50%", 
    "50%"), variable = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
    1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
    1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
    1L, 2L), .Label = c("alev", "dod"), class = "factor"), value = c(49.8, 
    101.6, 55.4, 12.7, 42.7, 22.6, 48.1, 32.5, 61.6, 38.9, 95.3, 
    17.1, 95.8, 24.8, 146.7, 0, 120.4, 5.2, 167.2, 12.3, 122, 10.6, 
    167.5, 29.5, 120, 13.5, 143.2, 34.4, 109.4, 13.9, 153.1, 19.4, 
    82.1, 26.2, 92.4, 28, 159, 7.6, 141.5, 44.5, 123.9, 15.6)), class = "data.frame", row.names = c(NA, 
    -42L), .Names = c("yta", "avd", "beh", "variable", "value"))

我为它做了一个ggplot

ggplot(aes(x = paste(yta, beh, sep = ":"), y = value, fill = variable), data = thin50) + stat_summary(fun.y = mean, geom = "bar", position = "stack") +
  #scale_fill_grey() + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  theme(axis.line = element_line(colour = "black"),
        axis.text = element_text(color = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_blank(),
        panel.background = element_blank(),
        legend.position = "bottom",
        text = element_text(size=14, color = "black", vjust = 0.5)) +
  labs(x = "Experiment : treatment", y = expression(m^3))

为什么我得到x值为“1105-50%”的反色 enter image description here

我尝试将dod值人为地添加到1105-UN,但它没有帮助。

0 个答案:

没有答案