내 데이터 프레임은 다음과 같습니다.
thin50 <- structure(list(yta = c(1102L, 1102L, 1102L, 1103L, 1103L, 1105L,
1105L, 1105L, 1107L, 1107L, 1107L, 1108L, 1108L, 1108L, 1109L,
1109L, 1110L, 1110L, 1110L, 1113L, 1113L, 1102L, 1102L, 1102L,
1103L, 1103L, 1105L, 1105L, 1105L, 1107L, 1107L, 1107L, 1108L,
1108L, 1108L, 1109L, 1109L, 1110L, 1110L, 1110L, 1113L, 1113L,
1102L, 1102L, 1102L, 1103L, 1103L, 1105L, 1105L, 1105L, 1107L,
1107L, 1107L, 1108L, 1108L, 1108L, 1109L, 1109L, 1110L, 1110L,
1110L, 1113L, 1113L), avd = c(6L, 7L, 1L, 2L, 5L, 2L, 3L, 5L,
2L, 7L, 3L, 3L, 1L, 4L, 1L, 2L, 2L, 5L, 6L, 3L, 2L, 6L, 7L, 1L,
2L, 5L, 2L, 3L, 5L, 2L, 7L, 3L, 3L, 1L, 4L, 1L, 2L, 2L, 5L, 6L,
3L, 2L, 6L, 7L, 1L, 2L, 5L, 2L, 3L, 5L, 2L, 7L, 3L, 3L, 1L, 4L,
1L, 2L, 2L, 5L, 6L, 3L, 2L), beh = c("50%", "50%", "UN", "50%",
"UN", "50%", "50%", "UN", "50%", "50%", "UN", "50%", "UN", "UN",
"50%", "UN", "50%", "50%", "UN", "50%", "UN", "50%", "50%", "UN",
"50%", "UN", "50%", "50%", "UN", "50%", "50%", "UN", "50%", "UN",
"UN", "50%", "UN", "50%", "50%", "UN", "50%", "UN", "50%", "50%",
"UN", "50%", "UN", "50%", "50%", "UN", "50%", "50%", "UN", "50%",
"UN", "UN", "50%", "UN", "50%", "50%", "UN", "50%", "UN"), variable = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Htveg",
"dod", "sumut"), class = "factor"), value = c(313, 299.6, 353.7,
267.8, 392.9, 191.3, 191.4, 353.4, 238, 226.2, 419.6, 273, 410,
370.6, 317, 515.1, 142.5, 160, 341, 324.5, 447.9, 12.7, 22.6,
101.6, 32.5, 38.9, 17.1, 24.8, 0, 5.2, 10.6, 12.3, 13.5, 29.5,
34.4, 13.9, 19.4, 26.2, 28, 7.6, 15.6, 44.5, 89.6, 92.6, 0, 86.4,
0, 100.4, 119.9, 0, 121.1, 112.9, 0, 90.1, 0, 0, 59.6, 0, 79.6,
83.1, 0, 115.3, 0)), row.names = c(NA, -63L), .Names = c("yta",
"avd", "beh", "variable", "value"), class = "data.frame")
막대 플롯을 수행합니다.
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 = "none",
text = element_text(size=14, color = "black", vjust = 0.5)) +
labs(x = "Experiment : treatment", y = expression(m^3) )
그리고이 수치를 얻습니다.
진한 회색이 밝은 회색 인 y 축의 순서를 어떻게 변경할 수 있습니까?
누적 순서를 변경하려면 먼저 요인 수준의 순서를 변경해야합니다. 예 :
thin50$variable <- factor(thin50$variable, levels=c("Htveg", "sumut", "dod"))
색상이 동일한 순서로 유지되기를 원하거나 요인 수준에 대해 동일하게 유지되어야하는지 여부는 나에게 완전히 명확하지 않으므로 다음을 유지 scale_fill_grey()
하거나 추가 할 수 있습니다 scale_fill_manual()
.
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() +
scale_fill_manual(values=c("black", "lightgrey", "darkgrey")) +
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 = "none",
text = element_text(size=14, color = "black", vjust = 0.5)) +
labs(x = "Experiment : treatment", y = expression(m^3))
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다