-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotting.r
executable file
·44 lines (39 loc) · 1.21 KB
/
plotting.r
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
list.of.packages <- c("rgl", "dplyr")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
library(rgl)
library(dplyr)
mat1 <- matrix(c(.7, -.7, 0, 0,
.3, .3, .9, 0,
-.7, -.7, .4, 0,
0, 0, 0, 1), nrow=4, ncol=4, byrow=TRUE)
col <- rainbow(100)
color_pallet <- function(x){
for(i in 1:99){
if(y[[i+1]][1]>x & x>=y[[i]][1]){
return(col[i])
}
}
return(col[100])
}
data <- read.table("model_data.csv") %>%
rename(x = V1, y = V2, v = V3)
v.min <- min(data$v)
v.max <- max(data$v)
v.split <- split(data$v[order(data$v)], ceiling(seq_along(data$v)/(length(data$v)/100)))
y <- v.split
col <- rainbow(100)
color_pallet <- function(x){
for(i in 1:99){
if(y[[i+1]][1]>x & x>=y[[i]][1]){
return(col[i])
}
}
return(col[100])
}
v.colors <- unlist(sapply(data$v, color_pallet))
par3d(windowRect = c(0, 0, 480, 480))
plot3d(data$x, data$y, data$v, type="p", col=v.colors,
zlim=c(v.min, v.max), box=FALSE, xlab="", ylab="", zlab="", lit=FALSE)
## rgl.viewpoint(scale=c(1, 1, 1), userMatrix=mat1)
## snapshot3d("plot.png")