td_plot <- gps_data %>%
filter(Date == '2018-02-17') %>%
mutate(
Name = forcats::fct_reorder( Name, dist_total, desc=T)
) %>%
ggplot(aes(Name, dist_total, fill = `Position Specific`,
label = paste0(round(dist_total, 0),"m"))) +
geom_col() +
coord_flip() +
geom_text(hjust=1) +
bbplot::bbc_style() +
labs(y = "Total Distance", x = 'Player Name',
fill='Position', title = 'Total Distance Covered', type='Garamond') +
theme(
axis.text.x = element_blank(),
axis.text.y = element_text(size=14),
axis.ticks.x = element_blank(),
legend.justification=c(1,0),
legend.position=c(1,0),
legend.text = ggplot2::element_text(size=8,
color="#222222"))
hsr_plot <- gps_data %>%
filter(Date == '2018-02-17') %>%
mutate(
Name = forcats::fct_reorder( Name, dist_total, desc=T)
) %>%
ggplot(aes(Name, hsr_total, fill=`Position Specific`, label=
paste0(round(hsr_total, 0),"m"))) +
geom_col() +
coord_flip() +
geom_text(hjust=1) +
bbplot::bbc_style() +
labs(y = "High Speed Distance", x = 'Player Name',
fill='Position', title = 'High Speed Distance Covered', type='Garamond') +
theme(
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
legend.position = "none"
)
cowplot::plot_grid(td_plot, hsr_plot)
You can also embed plots, for example:
td_plot <- gps_data %>%
filter(Date == '2018-02-17') %>%
mutate(
Name = forcats::fct_reorder( Name, dist_total, desc=T),
tooltip = paste0(Name, "\n",`Position Specific`, "\n", round(hsr_total, 0),"m")
) %>%
ggplot(aes(Name, dist_total, fill = `Position Specific`,
label = paste0(round(dist_total, 0),"m"))) +
ggiraph::geom_bar_interactive(aes(y=dist_total, fill=`Position Specific`, tooltip=tooltip),stat = 'identity') +
coord_flip() +
geom_text(hjust=1, size=2) +
bbplot::bbc_style() +
labs(y = "Total Distance", x = 'Player Name',
fill='Position', title = 'Total Distance Covered', type='Garamond') +
theme(
axis.text.x = element_blank(),
axis.text.y = element_text(size=14),
axis.ticks.x = element_blank(),
legend.text = ggplot2::element_text(size=4,
color="#222222"),
legend.justification=c(1,0),
legend.position=c(1,0),
legend.spacing.x = unit(0.06, 'cm'),
plot.title = element_text(size=10))
hsr_plot <- gps_data %>%
filter(Date == '2018-02-17') %>%
mutate(
Name = forcats::fct_reorder( Name, dist_total, desc=T),
tooltip = paste0(Name, "\n",`Position Specific`, "\n", round(hsr_total, 0),"m")
) %>%
ggplot(aes(Name, hsr_total, , label=
paste0(round(hsr_total, 0),"m"))) +
ggiraph::geom_bar_interactive(aes(y=hsr_total, fill=`Position Specific`, tooltip=tooltip),stat = 'identity') +
coord_flip() +
geom_text(hjust=1, size=2) +
bbplot::bbc_style() +
labs(y = "High Speed Distance", x = 'Player Name',
fill='Position', title = 'High Speed Distance Covered', type='Garamond') +
theme(
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
legend.position = "none",
plot.title = element_text(size=10)
)
ggiraph_plots <- cowplot::plot_grid(td_plot, hsr_plot)
ggiraph::girafe(code=print(ggiraph_plots))
td_plot <- gps_data %>%
filter(Date == '2018-02-17') %>%
mutate(
Name = forcats::fct_reorder( Name, dist_total, desc=T)
) %>%
ggplot(aes(Name, dist_total, fill = `Position Specific`,
label = paste0(round(dist_total, 0),"m")))+
geom_col() +
coord_flip() +
geom_text(hjust=1) +
bbplot::bbc_style() +
theme(
axis.text.x = element_blank(),
axis.text.y = element_text(size=14),
axis.ticks.x = element_blank(),
legend.justification=c(1,0),
legend.position=c(1,0))
td_plot <- plotly::ggplotly(td_plot)
hsr_plot <- gps_data %>%
filter(Date == '2018-02-17') %>%
mutate(
Name = forcats::fct_reorder(Name, dist_total, desc=T)
) %>%
ggplot(aes(Name, hsr_total, fill=`Position Specific`,
label = paste0(round(hsr_total, 0),"m")))+
geom_col() +
coord_flip() +
geom_text(hjust=1) +
bbplot::bbc_style() +
theme(
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks.x = element_blank())
hsr_plot <- plotly::ggplotly(hsr_plot)
plotly::subplot(plotly::style(td_plot,hoverinfo=c('y+x')), plotly::style(hsr_plot, hoverinfo=c('y+x'))) %>%
plotly::layout(title="Comparison of Total Distance to High Speed Running",
titlefont=10, showlegend=TRUE, legend = list(font = list(size = 8)))
library(dygraphs)
library(xts)
ts_data <- gps_data %>%
filter(Name == '04fa3')%>%
select(Date, dist_total, hsr_total)
names <- c('Date', 'Total Distance', 'High Speed Distance')
colnames(ts_data) <- names
gps_ts <- xts(x = ts_data,
order.by = ts_data$Date)
dygraph(gps_ts, main = 'Seasonal Total Distance and High Speed Distance Data') %>%
dyRangeSelector(dateWindow = c(max(ts_data$Date)-30, max(ts_data$Date))) %>%
dyAxis("y", label = "Meters", valueRange = c(0, 10000)) %>%
dyHighlight(highlightCircleSize = 4,
highlightSeriesBackgroundAlpha = 0.5,
hideOnMouseOut = TRUE) %>%
dyLegend(show = "follow") %>%
dyOptions(drawPoints = TRUE, pointSize = 2) %>%
dyAxis("x", drawGrid = FALSE) %>%
dySeries("High Speed Distance", fillGraph = TRUE, color = "red")
library(rChartsCalmap)
ts_data <- gps_data %>%
filter(Name == '04fa3') %>%
mutate(
dist_total = round(dist_total, 0)
)
r1 <- calheatmap(x = 'Date', y = 'dist_total',
data = ts_data,
domain = 'month',
subDomain = "day",
start = min(gps_data$Date),
itemName = 'm',
legend = seq(0,10000, 2000))
r1
source("https://raw.githubusercontent.com/iascchen/VisHealth/master/R/calendarHeat.R")
test <- calendarHeat(ts_data$Date, ts_data$dist_total, color = "g2r")
## Loading required package: lattice
## Loading required package: grid
## Loading required package: chron