政务大数据应用与分析 (80700673)
清华大学社会科学学院
图之劣势
表之优势
作图为了什么?
Even before he became president, Mr Trump had a history of controversial comments about women. His comments in a 2005 Access Hollywood tape about grabbing women “by the pussy” are perhaps the most notorious, and made headlines in 2016…..”The kind of things that he said about Hillary Clinton, Carly Fiorina, Elizabeth Warren, Heidi Cruz—the list goes on—he talks about women, any prominent, powerful woman, in the most DEMEANING of ways, trivializing them.”(Rogers 2016)
Kastellec and Leoni (2007): APSR,AJPS和PA 2006年五刊
1. 准确
如何可视化以下数据?
| 政党 | 得票率 |
|---|---|
| A | 38 |
| B | 34 |
| C | 24 |
| D | 4 |
1. 准确
2. 明确
Marks: Min, 25%, 50%, 75%, Max
1. 准确
2. 明确
3. 详确
| 学生 | 原始成绩 | 补习班周数 | 进步分数 |
|---|---|---|---|
| A | 712 | 18 | 100 |
| B | 1105 | 4 | 57 |
| C | 690 | 7 | 80 |
| D | 687 | 27 | 191 |
| E | 725 | 2 | 5 |
| F | 1200 | 25 | 10 |
| G | 470 | 19 | 25 |
| H | 752 | 10 | 123 |
和之前的数据有什么不同
Pro
Con
Bonus
标记:点、线、面

通道:位置、大小、形状、方向、色调、饱和度、亮度……

统计可视化原则
准确·明确·详确
类型(Type)
有效性(Effectiveness)
表现力(Expressiveness)
\[\displaystyle S (I)=kI^{n},\]
k: proportionality constant that depends on the units used
Warning
入门容易,坑较深(没大必要入)
我们进一步深化对中国式现代化的内涵和本质的认识,概括形成中国式现代化的中国特色、本质要求和重大原则,初步构建中国式现代化的理论体系,使中国式现代化更加清晰、更加科学、更加可感可行。(习近平 2024)
The art of any propagandist and agitator consists in his ability to find the best means of influencing any given audience, by presenting a definite truth, in such a way as to make it most convincing, most easy to digest, most graphic, and most strongly impressive (Lenin 1974).
常见绘图工具
Tableau (Echarts)
Google Refine
Processing
D3 (JS)
R
常见可视化类型:
ggplot(data = mydata2,
aes(Catergory, value,
fill = variable)) +
geom_bar(
stat = "identity",
color = "black",
position = position_dodge(),
width = 0.7,
size = 0.25
) +
drhutools::scale_fill_gb() +
theme_minimal() +
ylim(0, 10) +
theme(
axis.title = element_text(size = 15, face = "plain", color = "black"),
axis.text = element_text(size = 12, face = "plain", color = "black"),
legend.title = element_text(size = 14, face = "plain", color = "black"),
legend.background = element_blank(),
legend.position = c(0.88, 0.88)
)| car | id | value |
|---|---|---|
| 数学 | 1 | 12 |
| 语文 | 2 | 2 |
| 英语 | 3 | 14 |
| 政治 | 4 | 20 |
| 编程 | 5 | 18 |
ggplot() +
geom_polygon(
data = mydata,
aes(x = id, y = value),
color = "black",
fill = brewer.pal(7, "Set1")[1],
alpha = 0.1
) +
geom_point(
data = mydata,
aes(x = id, y = value),
size = 5,
shape = 21,
color = 'black',
fill = brewer.pal(7, "Set1")[1]
) +
coord_radar() +
scale_x_continuous(breaks = label_data$id, labels = label_data$car) +
ylim(0, 22) +
theme_light() +
theme(axis.text.x = element_text(
size = 11,
colour = "black"
))ggplot(data = mydata, aes(x, y)) +
geom_point(
fill = "black",
colour = "black",
size = 3,
shape = 21
) +
geom_smooth(
method = 'loess',
span = 0.4,
se = TRUE,
colour = "#00A5FF",
fill = "#00A5FF",
alpha = 0.2
) +
scale_y_continuous(breaks = seq(0, 125, 25)) +
theme(
text = element_text(size = 15, color = "black"),
plot.title = element_text(
size = 15,
family = "myfont",
hjust = .5,
color = "black"
),
legend.position = "none"
)| (1) | (2) | (3) | |
|---|---|---|---|
| + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001 | |||
| (Intercept) | 43.540*** | 37.363*** | 37.742*** |
| (4.860) | (5.972) | (6.023) | |
| wt | -3.793** | -3.714** | -3.310** |
| (1.082) | (1.048) | (1.159) | |
| cyl | -1.784** | -1.119 | -1.086 |
| (0.614) | (0.714) | (0.719) | |
| disp | 0.007 | 0.014 | 0.013 |
| (0.012) | (0.012) | (0.012) | |
| gear | -0.490 | 0.679 | 0.120 |
| (0.790) | (1.035) | (1.234) | |
| hp | -0.028 | -0.029+ | |
| (0.017) | (0.017) | ||
| am | 1.465 | ||
| (1.743) | |||
| Num.Obs. | 32 | 32 | 32 |
| R2 | 0.835 | 0.851 | 0.855 |
| R2 Adj. | 0.811 | 0.822 | 0.820 |
| AIC | 159.1 | 157.8 | 158.9 |
| BIC | 167.9 | 168.1 | 170.6 |
| Log.Lik. | -73.553 | -71.906 | -71.460 |
| F | 34.149 | 29.723 | 24.608 |
| RMSE | 2.41 | 2.29 | 2.26 |
interplot)| Unique | Missing Pct. | Mean | SD | Min | Median | Max | Histogram | |
|---|---|---|---|---|---|---|---|---|
| mpg | 25 | 0 | 20.1 | 6.0 | 10.4 | 19.2 | 33.9 | ![]() |
| cyl | 3 | 0 | 6.2 | 1.8 | 4.0 | 6.0 | 8.0 | ![]() |
| disp | 27 | 0 | 230.7 | 123.9 | 71.1 | 196.3 | 472.0 | ![]() |
| hp | 22 | 0 | 146.7 | 68.6 | 52.0 | 123.0 | 335.0 | ![]() |
| drat | 22 | 0 | 3.6 | 0.5 | 2.8 | 3.7 | 4.9 | ![]() |
| wt | 29 | 0 | 3.2 | 1.0 | 1.5 | 3.3 | 5.4 | ![]() |
| qsec | 30 | 0 | 17.8 | 1.8 | 14.5 | 17.7 | 22.9 | ![]() |
| carb | 6 | 0 | 2.8 | 1.6 | 1.0 | 2.0 | 8.0 | ![]() |
| N | % | |||||||
| vs | FALSE | 18 | 56.2 | |||||
| TRUE | 14 | 43.8 | ||||||
| am | FALSE | 19 | 59.4 | |||||
| TRUE | 13 | 40.6 | ||||||
| gear | 3 | 15 | 46.9 | |||||
| 4 | 12 | 37.5 | ||||||
| 5 | 5 | 15.6 |
| (1) | (2) | (3) | |
|---|---|---|---|
| + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001 | |||
| (Intercept) | 43.540*** | 37.363*** | 37.742*** |
| (4.860) | (5.972) | (6.023) | |
| wt | -3.793** | -3.714** | -3.310** |
| (1.082) | (1.048) | (1.159) | |
| cyl | -1.784** | -1.119 | -1.086 |
| (0.614) | (0.714) | (0.719) | |
| disp | 0.007 | 0.014 | 0.013 |
| (0.012) | (0.012) | (0.012) | |
| gear | -0.490 | 0.679 | 0.120 |
| (0.790) | (1.035) | (1.234) | |
| hp | -0.028 | -0.029+ | |
| (0.017) | (0.017) | ||
| am | 1.465 | ||
| (1.743) | |||
| Num.Obs. | 32 | 32 | 32 |
| R2 | 0.835 | 0.851 | 0.855 |
| R2 Adj. | 0.811 | 0.822 | 0.820 |
| AIC | 159.1 | 157.8 | 158.9 |
| BIC | 167.9 | 168.1 | 170.6 |
| Log.Lik. | -73.553 | -71.906 | -71.460 |
| F | 34.149 | 29.723 | 24.608 |
| RMSE | 2.41 | 2.29 | 2.26 |