# 设置选项
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
# 加载必要的包
library(ggplot2)
开国大典
# 创建建国初期重要事件数据
important_events <- data.frame(
年份 = c(1949, 1950, 1951, 1952, 1953, 1954, 1955),
事件 = c("新中国成立", "土地改革开始", "抗美援朝", "第一个五年计划", "社会主义改造", "第一部宪法", "万隆会议"),
重要性 = c(10, 8, 9, 7, 8, 7, 6)
)
# 绘制时间线图表
ggplot(important_events, aes(x = 年份, y = 重要性)) +
geom_line(color = "red", size = 1.5) +
geom_point(color = "darkred", size = 3) +
geom_text(aes(label = 事件), vjust = -1, size = 3) +
labs(title = "建国初期重要事件时间线",
x = "年份",
y = "历史重要性") +
theme_minimal()
# 创建经济发展数据
years <- 1949:1960
gdp_growth <- c(100, 120, 145, 168, 195, 225, 260, 300, 320, 350, 380, 420)
industrial_output <- c(100, 180, 250, 320, 400, 500, 620, 750, 850, 950, 1080, 1200)
# 创建数据框
economic_data <- data.frame(
年份 = years,
GDP指数 = gdp_growth,
工业产值指数 = industrial_output
)
# 转换数据格式 - 使用基础R方法避免包依赖问题
economic_long <- data.frame(
年份 = rep(years, 2),
指标 = c(rep("GDP指数", length(years)), rep("工业产值指数", length(years))),
数值 = c(gdp_growth, industrial_output)
)
# 绘制经济发展趋势图
ggplot(economic_long, aes(x = 年份, y = 数值, color = 指标, group = 指标)) +
geom_line(size = 1.2) +
geom_point(size = 2) +
scale_color_manual(values = c("red", "darkblue")) +
labs(title = "建国初期经济发展趋势(1949-1960)",
y = "发展指数(1949=100)",
color = "经济指标") +
theme_minimal()
南昌起义
# 创建军队发展数据
military_data <- data.frame(
年份 = c(1927, 1937, 1945, 1949, 1960, 1970, 1980, 1990, 2000, 2010, 2020),
总兵力 = c(20000, 80000, 1200000, 5500000, 3200000, 2800000, 4200000, 3200000, 2500000, 2300000, 2000000),
技术装备水平 = c(1, 3, 5, 6, 15, 25, 45, 65, 85, 95, 100)
)
# 绘制军队发展历程图
ggplot(military_data, aes(x = 年份)) +
geom_line(aes(y = 总兵力/10000, color = "总兵力(万)"), size = 1.2) +
geom_line(aes(y = 技术装备水平, color = "技术装备水平指数"), size = 1.2) +
scale_y_continuous(
name = "总兵力(万)",
sec.axis = sec_axis(~., name = "技术装备水平指数")
) +
scale_color_manual(values = c("red", "blue")) +
labs(title = "人民军队发展历程",
color = "指标",
caption = "数据来源:模拟数据") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"))
# 创建现代化军队构成数据
modern_military <- data.frame(
军种 = c("陆军", "海军", "空军", "火箭军", "战略支援部队"),
占比 = c(40, 20, 18, 12, 10),
现代化指数 = c(85, 90, 95, 98, 96)
)
# 绘制军种构成图
ggplot(modern_military, aes(x = reorder(军种, -占比), y = 占比, fill = 现代化指数)) +
geom_col() +
geom_text(aes(label = paste0(占比, "%")), vjust = -0.5, size = 4) +
scale_fill_gradient(low = "lightblue", high = "darkred") +
labs(title = "各军种人员构成比例及现代化水平",
x = "军种",
y = "人员比例(%)") +
theme_minimal()
# 创建军民融合发展数据
fusion_data <- data.frame(
年份 = 2010:2020,
军民融合指数 = c(30, 35, 42, 50, 58, 65, 72, 78, 83, 87, 90),
国防预算占GDP比例 = c(1.8, 1.8, 1.9, 1.9, 2.0, 2.1, 2.1, 2.1, 2.2, 2.2, 2.2)
)
# 绘制军民融合发展趋势图
ggplot(fusion_data, aes(x = 年份)) +
geom_area(aes(y = 军民融合指数), fill = "red", alpha = 0.3) +
geom_line(aes(y = 军民融合指数), color = "red", size = 1.5) +
geom_line(aes(y = 国防预算占GDP比例 * 30), color = "blue", size = 1.5) +
scale_y_continuous(
name = "军民融合指数",
sec.axis = sec_axis(~./30, name = "国防预算占GDP比例(%)")
) +
labs(title = "军民融合发展趋势与国防投入",
caption = "注:国防预算比例已做标度转换以便于比较") +
theme_minimal()
# 创建综合成就对比数据
achievement <- data.frame(
时期 = c("建国初期", "改革开放初期", "新时代"),
综合国力指数 = c(30, 60, 95),
国防实力指数 = c(25, 55, 90),
人民生活水平指数 = c(20, 50, 85)
)
# 转换数据格式 - 使用基础R方法
achievement_long <- data.frame(
时期 = rep(achievement$时期, 3),
指标 = c(rep("综合国力指数", 3), rep("国防实力指数", 3), rep("人民生活水平指数", 3)),
指数 = c(achievement$综合国力指数, achievement$国防实力指数, achievement$人民生活水平指数)
)
# 绘制成就对比图
ggplot(achievement_long, aes(x = 时期, y = 指数, fill = 指标)) +
geom_col(position = "dodge") +
scale_fill_manual(values = c("red", "blue", "darkgreen")) +
labs(title = "不同时期发展成就对比",
x = "时期",
y = "发展指数") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
legend.position = "bottom")