-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path9-34 plot remade.Rmd
More file actions
39 lines (28 loc) · 991 Bytes
/
9-34 plot remade.Rmd
File metadata and controls
39 lines (28 loc) · 991 Bytes
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
---
title: "9-34Plot remade"
author: "Hao Li"
date: "3/23/2021"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
#Brownian motion problem revisited with new visualization mappings
library(ggplot2)
set.seed(123)
#prepare data 2D
n=64
n_step = 128
tune_mean = 0
tune_sd = 1
xyDf = NULL
for(i in 1:n){
xyDf=rbind(xyDf,data.frame(t = 1:n_step,x = cumsum(rnorm(n_step,mean = tune_mean,sd = tune_sd)),y = cumsum(rnorm(n_step,mean = tune_mean,sd = tune_sd)),n = rep(i,n_step)))
}
xyDf$n = factor(xyDf$n)
g = ggplot(data = xyDf,aes(x = x,y = y,group =n,color = n)) + geom_point(alpha = .3,size = .2) +geom_path(aes(alpha = -t)) + theme(legend.position = "none")#+ scale_color_distiller(palette = "Spectral")
g
g2 = ggplot(data = xyDf[xyDf$n==1,],aes(x = x,y = y,alpha = -t)) + geom_point(size = .2) +geom_path() + theme(legend.position = "none")#+ scale_color_distiller(palette = "Spectral")
g2
```