-
[R] 두개의 세로축 그리기 (dual y-axis)R 2020. 8. 19. 17:55
> ggplot(data, aes(x = a) +
geom_bar(aes(y = b), stat = "identity", fill = "cornflowerblue") +
geom_text(aes(x = a, y = b, label = c), position = position_dodge(width = 0.5), size = 3.5, vjust = 1.0) +
geom_line(aes(y = c * max_ratio), group = 1, color = "orange", size = 2, alpha = 0.5) +
geom_point(aes(y = c * max_ratio), color = "red", size = 3, alpha = 0.2) +
scale_y_continuous(name = "d", sec.axis = sec.axis(~. / max_ratio, name = "e")) +
geom_text(aes(x = a, y = c * max_ratio, label = c), position = position_dodge(width = 0.5), size = 3.5, vjust = 1.0)+
theme(axis.title.x = element_blank(), axis.text.x = element_text(angle = 30))
'R' 카테고리의 다른 글
[R] caret 패키지 confusion matrix (2 by 2 case) (0) 2020.11.12 [R] k-fold cv using caret package (0) 2020.11.03 [R] SMOTE (0) 2020.09.28 [R] ROC curve (0) 2020.08.20 [R] 하나의 key-id 에 대한 중복 row 제거 (duplicated) (0) 2020.08.05