-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal-plot.R
66 lines (56 loc) · 1.99 KB
/
global-plot.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# IVA 2.5.17
library(plotly)
library(dplyr)
library(tidyr)
plotlyMarkersLines <- function(){
trace_0 <- rnorm(100, mean = 5)
trace_1 <- rnorm(100, mean = 0)
trace_2 <- rnorm(100, mean = -5)
x <- c(1:100)
data <- data.frame(x, trace_0, trace_1, trace_2)
p <- plot_ly(data, x = ~x, y = ~trace_0, name = 'trace 0', type = 'scatter', mode = 'lines') %>%
add_trace(y = ~trace_1, name = 'trace 1', mode = 'lines+markers') %>%
add_trace(y = ~trace_2, name = 'trace 2', mode = 'markers') %>%
layout(title = "title",
xaxis = list(title = "Days"),
yaxis = list(title = "Temp"))
p
}
plotlyNAMarkersLines <- function(){
trace_0 <- rnorm(365, mean = 5, sd = 30)
trace_1 <- trace_0
trace_3 <- trace_0
trace_3[sample(length(trace_0), 33)] <- NA
trace_0[sample(length(trace_0), 33)] <- NA
x <- c(1:365)
data <- data.frame(x, trace_0, trace_1, trace_3)
colz <- c('#FE8268', '#81E8FE', '#FED681', '#81FED6', '#FE81A9')
p <- plot_ly(data, x = ~x,
y = ~trace_1, name = 'trace 1', type = 'scatter', mode = 'markers') %>% # , hoverinfo = "none"
add_trace(y = ~trace_0, name = 'trace 0', mode = 'markers') %>%
add_trace(y = ~trace_3, name = 'trace 3', mode = 'markers') %>%
layout(title = "title",
xaxis = list(title = "Days"),
yaxis = list(title = "Temp")) %>%
rangeslider()
p
}
plotlyVect <- function(vec.na, vec.impute, vec.title, vec.ysxis, vec.xaxis) {
days<- 1:length(vec.impute)
data <- data.frame(days, vec.na, vec.impute)
p <- plot_ly(data, x = ~days, y= ~vec.impute, name = 'vec.impute',type = 'scatter', mode = 'markers') %>%
add_trace(y = ~vec.na, name = 'vec.na', mode = 'markers') %>%
layout(title = vec.title,
xaxis = list(title = vec.xaxis),
yaxis = list(title = vec.ysxis)) %>%
rangeslider()
p
}
if (FALSE){
plotlyNAMarkersLines()
}
if (FALSE){
plotlyMarkersLines()
}
if (FALSE) {
}