- Part I.
배경 - Part II.
기존 시각화 그래프 분석 - Part III.
시각화 한계를 보완한 대안 제시 - Part IV.
결론
배경기존 시각화 그래프 분석시각화 한계를 보완한 대안 제시결론배경Code highlight
htmlwidget 사용 가능, web에 간편하게 게시가능beamer기존 시각화 그래프 분석Sources of Gallium and Germanium Imported Into US Gallium(갈륨), Germanium(저마늄).국가별 공급율
Sources of Gallium and Germanium Imported Into US 결론
#각 국가별 갈륨, 저마늄 공급율 (%)
| 자원 | 중국 | 벨기에 | 독일 | 러시아 | 일본 | 캐나다 | 기타 |
|---|---|---|---|---|---|---|---|
| 갈륨 | 22% | - | 18% | - | 23% | 9% | 28% |
| 저마늄 | 54% | 30% | 8% | 6% | - | - | 2% |
저마늄: 중국에 거의 전적으로 의존(약 95%), 벨기에에서 소량 수입.갈륨: 중국이 최대 공급국(약 50%)이지만, 일본, 캐나다, 러시아 등 다른 국가들도 기여.전략적 우려: 중국에 대한 높은 의존도는 공급망 다변화의 필요성을 강조.시각화 한계를 보완한 대안 제시YAML header
data_1 <- data.frame(
Material = rep("Germanium", 5),
Country = c("China", "Belgium", "Germany", "Russia", "Others"),
Percentage = c(54, 30, 8, 6, 2)
)
data_2 <- data.frame(
Material = rep("Gallium", 5),
Country = c("China", "Germany", "Japan", "Canada", "Others"),
Percentage = c(22, 18, 28, 23, 9)
)
library(ggplot2) library(dplyr)
## ## 다음의 패키지를 부착합니다: 'dplyr'
## The following objects are masked from 'package:stats': ## ## filter, lag
## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union
# 데이터 생성
data_1 <- data.frame(
Material = rep("Germanium", 5),
Country = c("China", "Belgium", "Germany", "Russia", "Others"),
Percentage = c(54, 30, 8, 6, 2)
)
data_2 <- data.frame(
Material = rep("Gallium", 5),
Country = c("China", "Germany", "Japan", "Canada", "Others"),
Percentage = c(22, 18, 28, 23, 9)
)
# 두 데이터를 병합 후 내림차순 정렬
data <- rbind(data_1, data_2)
print(data_1)
## Material Country Percentage ## 1 Germanium China 54 ## 2 Germanium Belgium 30 ## 3 Germanium Germany 8 ## 4 Germanium Russia 6 ## 5 Germanium Others 2
print(data_2)
## Material Country Percentage ## 1 Gallium China 22 ## 2 Gallium Germany 18 ## 3 Gallium Japan 28 ## 4 Gallium Canada 23 ## 5 Gallium Others 9
print(data)
## Material Country Percentage ## 1 Germanium China 54 ## 2 Germanium Belgium 30 ## 3 Germanium Germany 8 ## 4 Germanium Russia 6 ## 5 Germanium Others 2 ## 6 Gallium China 22 ## 7 Gallium Germany 18 ## 8 Gallium Japan 28 ## 9 Gallium Canada 23 ## 10 Gallium Others 9
# Country 순서를 Material별로 독립적으로 설정
data <- data %>%
mutate(Country = case_when(
Material == "Germanium" ~ factor(Country, levels = c("China", "Belgium", "Germany", "Russia", "Others")),
Material == "Gallium" ~ factor(Country, levels = c("Others", "Japan", "China", "Germany", "Canada"))
))
# 사용자 지정 색상
country_colors <- c(
"China" = "#000000",
"Belgium" = "#E2358A",
"Germany" = "#CCCCCC",
"Russia" = "#5FAEF9",
"Japan" = "#F1C440",
"Canada" = "#89F29D",
"Others" = "#2F46F6"
)
library(dplyr)
# Material별 Percentage 합계 기준 정렬
data <- data %>%
group_by(Material) %>%
mutate(Material = factor(Material, levels = Material[order(-sum(Percentage))]))
# 가로 누적 막대그래프 생성
ggplot(data, aes(x = Material, y = Percentage, fill = Country)) +
geom_bar(stat = "identity", position = "stack", color = "black") +
geom_text(aes(label = ifelse(Percentage > 0, paste0(Percentage, "%"), "")),
position = position_stack(vjust = 0.5), size = 3, color = "white") +
scale_fill_manual(values = country_colors) +
labs(
title = "Sources of Gallium and Germanium Imported Into US",
x = "Materials",
y = "Percentage (%)",
fill = "Country"
) +
coord_flip() + # 가로 방향 설정
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, size = 14),
axis.title = element_text(size = 12),
legend.title = element_text(size = 12),
legend.position = "right"
)
결론+ 기존 그래프는 비율을 누적 형태로 보여주어 전체 미국에 공급되는 갈륨과 저마늄이 어떤 국가로부터 공급이 되는지 전체 대비 비율적으로 표현은 잘되었으나, 대략적으나, 세부정보를 뺌으로서 각 국가별 공급율을 정확하게 알 수 없었습니다. + 레이블과 그리드 라인을 추가해서 더 정확한 공급율 (%)을 알 수 있도록 했으며, + 순서를 공급율이 높은 순으로 변경하여, 공급량이 높은 순으로 국가를 파악할 수 있도록 하였습니다.
"감사합니다"