足球比分热力图

足球比分热力图

本文为学习zonination/football-hmap的笔记。使用美国15741场足球比赛的结果绘制了一幅比赛结果的热力图。

数据集:games.csv

R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
games <- read.csv("games.csv", stringsAsFactors = F)
library(ggplot2)
library(viridis)

ggplot(games, aes(x = PtsW, y = PtsL)) +
geom_tile(aes(fill = Count), color = "black") +
scale_fill_viridis("总数", option = "viridis") +
scale_y_continuous(limits = c(-1, 51), breaks = seq(0, 50, 2)) +
scale_x_continuous(limits = c(-1, 76), breaks = seq(0, 80, 2)) +
labs(title = "图:足球历史上的比赛得分",
subtitle = "使用美国15741场足球比赛的结果绘制",
x = "丢失分数",
y = "赢得分数") +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) +
theme_bw(base_size = 20, base_family = "STSong") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(plot.subtitle = element_text(hjust = 0.5)) +
theme(panel.background=element_rect(fill = "#000000", color = "#F0F0F0"))+
theme(panel.grid.major=element_line(color = "#525252", size = 0.25))+
theme(panel.grid.minor=element_line(color = "#252525", size = 0.25))

# R

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×