Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Keisuke ANDO
socceR
Commits
52b0312f
Commit
52b0312f
authored
Apr 15, 2022
by
Takumi Amano
💬
Browse files
[add] ヒートマップとサッカーフィールドの描写できるようにした
parent
45d1390d
Changes
2
Show whitespace changes
Inline
Side-by-side
R/get_kick_point.R
0 → 100644
View file @
52b0312f
get_kick_point
<-
function
(
log_data
)
{
output
<-
log_data
|>
dplyr
::
filter
(
command
==
"kick"
)
|>
dplyr
::
mutate
(
x
=
args
|>
stringr
::
str_extract
(
"[0-9\\-\\.]+"
),
l1
=
args
|>
stringr
::
str_remove
(
x
),
y
=
l1
|>
stringr
::
str_extract
(
"[0-9\\-\\.]+"
),
)
|>
dplyr
::
select
(
step
,
team
,
unum
,
command
,
x
,
y
,
)
return
(
output
)
}
R/make_graphics.R
View file @
52b0312f
make_graph
<-
function
(
p_data
,
teamname
,
num
){
p
<-
ggplot
(
data
=
p_data
%>%
filter
(
team
==
teamname
,
unum
==
num
),
aes
(
x
=
as.numeric
(
x
),
y
=
as.numeric
(
y
)))
+
ggplot2
::
coord_fixed
(
xlim
=
c
(
-55
,
55
),
ylim
=
c
(
-35
,
35
))
+
geom_hline
(
yintercept
=
-34.1
,
linetype
=
"solid"
)
+
geom_hline
(
yintercept
=
34.1
,
linetype
=
"solid"
)
+
DEFAULT_MAX_PLAYER
<-
11
DEFAULT_PITCH_LENGTH
<-
105.0
DEFAULT_PITCH_WIDTH
<-
70.0
DEFAULT_PITCH_MARGIN
<-
5.0
DEFAULT_CENTER_CIRCLE_R
<-
9.15
DEFAULT_PENALTY_AREA_LENGTH
<-
16.5
DEFAULT_PENALTY_AREA_WIDTH
<-
40.32
DEFAULT_PENALTY_CIRCLE_R
<-
9.15
DEFAULT_PENALTY_SPOT_DIST
<-
11.0
DEFAULT_GOAL_AREA_LENGTH
<-
5.5
DEFAULT_GOAL_AREA_WIDTH
<-
18.32
DEFAULT_GOAL_DEPTH
<-
2.44
# DEFAULT_CORNER_ARC_R <- 1.0
half_p_l
<-
DEFAULT_PITCH_LENGTH
/
2
half_p_w
<-
DEFAULT_PITCH_WIDTH
/
2
penalty_x
<-
half_p_l
-
DEFAULT_PENALTY_AREA_LENGTH
penalty_y
<-
DEFAULT_PENALTY_AREA_WIDTH
/
2
goal_x
<-
half_p_l
-
DEFAULT_GOAL_AREA_LENGTH
goal_y
<-
DEFAULT_GOAL_AREA_WIDTH
/
2
make_field
<-
function
(
input_graph
){
p
<-
input_graph
+
geom_hline
(
yintercept
=
0
,
linetype
=
"solid"
)
+
geom_vline
(
xintercept
=
52.6
,
linetype
=
"solid"
)
+
geom_vline
(
xintercept
=
-52.6
,
linetype
=
"solid"
)
+
geom_vline
(
xintercept
=
0
,
linetype
=
"solid"
)
+
geom_linerange
(
aes
(
x
=
half_p_l
,
y
=
NULL
,
ymin
=-
half_p_w
,
ymax
=
half_p_w
))
+
geom_linerange
(
aes
(
x
=-
half_p_l
,
y
=
NULL
,
ymin
=-
half_p_w
,
ymax
=
half_p_w
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=
half_p_w
,
xmin
=-
half_p_l
,
xmax
=
half_p_l
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=-
half_p_w
,
xmin
=-
half_p_l
,
xmax
=
half_p_l
))
+
geom_point
(
size
=
0.1
)
+
geom_density_2d_filled
(
alpha
=
0.7
)
geom_linerange
(
aes
(
x
=
penalty_x
,
y
=
NULL
,
ymin
=-
penalty_y
,
ymax
=
penalty_y
))
+
geom_linerange
(
aes
(
x
=-
penalty_x
,
y
=
NULL
,
ymin
=-
penalty_y
,
ymax
=
penalty_y
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=
penalty_y
,
xmin
=
penalty_x
,
xmax
=
half_p_l
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=-
penalty_y
,
xmin
=
penalty_x
,
xmax
=
half_p_l
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=
penalty_y
,
xmax
=-
penalty_x
,
xmin
=-
half_p_l
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=-
penalty_y
,
xmax
=-
penalty_x
,
xmin
=-
half_p_l
))
+
geom_linerange
(
aes
(
x
=
goal_x
,
y
=
NULL
,
ymin
=-
goal_y
,
ymax
=
goal_y
))
+
geom_linerange
(
aes
(
x
=-
goal_x
,
y
=
NULL
,
ymin
=-
goal_y
,
ymax
=
goal_y
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=
goal_y
,
xmax
=
goal_x
,
xmin
=
half_p_l
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=-
goal_y
,
xmax
=
goal_x
,
xmin
=
half_p_l
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=
goal_y
,
xmin
=-
goal_x
,
xmax
=-
half_p_l
))
+
geom_linerange
(
aes
(
x
=
NULL
,
y
=-
goal_y
,
xmin
=-
goal_x
,
xmax
=-
half_p_l
))
+
ggforce
::
geom_circle
(
aes
(
x0
=
0
,
y0
=
0
,
r
=
DEFAULT_CENTER_CIRCLE_R
),
inherit.aes
=
FALSE
)
return
(
p
)
}
#ggplot2::geom_path(size=1.2,aes(color = as.numeric(step))) +
# +
# ggplot2::geom_density2d(size = 0.25, colour = "black")
\ No newline at end of file
make_heatmap
<-
function
(
p_data
){
p
<-
ggplot
(
data
=
p_data
,
aes
(
x
=
as.numeric
(
x
),
y
=
as.numeric
(
y
)))
+
ggplot2
::
coord_fixed
(
xlim
=
c
(
-
half_p_l
,
half_p_l
),
ylim
=
c
(
-
half_p_w
,
half_p_w
))
+
geom_density_2d_filled
(
alpha
=
0.5
)
p
<-
p
|>
make_field
()
return
(
p
)
}
# make_kick_point <- function(p_data,input_graph){
# log_data <- p_data
# p <- input_graph +
# geom_point(data = p_data,aes(x = as.numeric(x), y = as.numeric(y)))
# return(p)
# }
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment