- 그래프에서 하이라이트 적용하기(gghighlight)2023년 05월 29일 09시 36분 16초에 업로드 된 글입니다.작성자: r-code-for-data-analysis
여러 선들이 겹쳐있을 때 내가 중요하게 보는 것만 강조해서 보여주는 패키지가 "gghighlight" 이다.
https://yutannihilation.github.io/gghighlight/
Highlight Lines and Points in ggplot2
Make it easier to explore data with highlights.
yutannihilation.github.io
그러면 아래와 같이 여러개 선들 중 중요하게 보여주고 싶은 것만 색을 칠할 수 있다.
1. 패키지 설치 및 불러오기
install.packages("gghightligt") library(gghighlight)
2. 데이터 만들기
set.seed(2) d <- purrr::map_dfr( letters, ~ data.frame( idx = 1:400, value = cumsum(runif(400, -1, 1)), type = ., flag = sample(c(TRUE, FALSE), size = 400, replace = TRUE), stringsAsFactors = FALSE ) ) head(d)
3. 그래프 그리기
ggplot(d) + geom_line(aes(idx, value, colour = type)) + gghighlight(max(value) > 17) ggplot(d) + geom_line(aes(idx, value, colour = type)) + gghighlight(max(value) > 17) + theme_minimal() ggplot(d) + geom_line(aes(idx, value, colour = type)) + gghighlight(max(value) > 17) + theme_minimal() + facet_wrap(~ type)
728x90반응형'데이터 시각화' 카테고리의 다른 글
움직이는 그래프를 만들어보자(gganimation) (0) 2023.05.29 RSTUDIO로 gps 데이터 3d 시각화하기(rgl) (0) 2023.05.29 xyz 3열의 데이터를 2d, 3d로 시각화 해보기(plot_ly) (0) 2023.05.29 Sank Diagram 으로 QC 데이터 시각화 하기(ggalluvial) (0) 2023.05.29 RSTUIDO에서 boxplot, density, point를 한번에 그리는 법(ggdist) (0) 2023.05.29 댓글