-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_sim.Rmd
46 lines (40 loc) · 1.24 KB
/
path_sim.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
title: "Simulating path scoring"
author: "Mike Cuoco"
date: "2/15/2021"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(glue)
library(latex2exp)
library(patchwork)
ggplot2::theme_set(theme_bw())
```
```{r}
# simulate paths
data = map_df(1:50, function(p){
len = rep(p, p+1)
consec = 0:p
return(data.frame("length" = len, "consec" = consec))
})
alpha = list(0,0.1,0.5,1,5,10)
p.list = list()
p.list = map(alpha, function(a){
data %>%
mutate(scores = length + a*((length-1)-consec), alpha = a) %>%
ggplot(aes(x = consec, y = length, z = scores, fill = scores)) +
geom_tile() +
geom_contour(color = "white", alpha = 0.5) +
coord_equal() +
scale_fill_viridis_c() +
guides(fill = FALSE) +
labs(title = glue("alpha = {a}"), x = TeX('$unicolored(P)$'), y = TeX('$Edges(P)$'), fill = TeX('$Influence(P)$'))
# theme(legend.position = "left")
})
p = patchwork::wrap_plots(p.list, ncol = 3) + plot_annotation(title = TeX("$Influence(P)= Edges(P) + \\alpha \\cdot (Nodes(P) - unicolored(P))$"), subtitle = TeX("Colored by $Influence(P)$"))
ggsave(filename = "path_sim_alpha.png", width = 7, height = 5)
```