@@ -8,6 +8,7 @@ one.line.df <-
8
8
y = c(2 , 1 , 3 , 4 ),
9
9
array = c(0.1 , 0.2 , 0.1 , 0.1 ),
10
10
arrayminus = c(0.2 , 0.4 , 1 , 0.2 ))
11
+
11
12
one.line.json <- list (
12
13
list (
13
14
x = c(1 , 2 , 3 , 4 ),
@@ -28,9 +29,15 @@ test_that("asymmetric error bars, geom_errorbar last", {
28
29
geom_point()+
29
30
geom_errorbar(aes(ymin = y - arrayminus , ymax = y + array ))
30
31
generated.json <- gg2list(one.line.gg )
32
+ # # BUG: lines do not appear in plotly.
33
+ generated.json [[2 ]]$ mode <- " lines+markers"
34
+ # # when there is 1 trace with error bars, lines, and markers, plotly
35
+ # # shows error bars in the background, lines in the middle and
36
+ # # markers in front.
31
37
is.trace <- names(generated.json ) == " "
32
38
traces <- generated.json [is.trace ]
33
39
expect_identical(length(traces ), 1L )
40
+ # # TODO: check that data agrees in one.line.json and generated.json.
34
41
})
35
42
36
43
test_that(" asymmetric error bars, geom_errorbar first" , {
@@ -44,7 +51,36 @@ test_that("asymmetric error bars, geom_errorbar first", {
44
51
expect_identical(length(traces ), 1L )
45
52
})
46
53
54
+ colors.json <- list (
55
+ list (
56
+ x = c(1 , 2 , 3 , 4 ),
57
+ y = c(2 , 1 , 3 , 4 ),
58
+ error_y = list (
59
+ type = " data" ,
60
+ symmetric = FALSE ,
61
+ array = c(0.1 , 0.2 , 0.1 , 0.1 ),
62
+ arrayminus = c(0.2 , 0.4 , 1 , 0.2 ),
63
+ color = " red"
64
+ ),
65
+ type = " scatter" ,
66
+ marker = list (color = " blue" , size = 14 ),
67
+ line = list (color = " black" )
68
+ )
69
+ )
47
70
71
+ test_that(" different colors for error bars, points, and lines" , {
72
+ one.line.gg <- ggplot(one.line.df , aes(x , y ))+
73
+ geom_errorbar(aes(ymin = y - arrayminus , ymax = y + array ), color = " red" )+
74
+ geom_line(color = " black" )+
75
+ geom_point(color = " blue" , size = 14 )
76
+ generated.json <- gg2list(one.line.gg )
77
+ is.trace <- names(generated.json ) == " "
78
+ traces <- generated.json [is.trace ]
79
+ expect_identical(length(traces ), 1L )
80
+ # # TODO: check that colors agree in colors.json and generated.json.
81
+ })
82
+
83
+ if (FALSE ){
48
84
# # from https://github.com/chriddyp/ggplot2-plotly-cookbook/blob/a45f2c70b7adf484e0b0eb8810a1e59e018adbb8/means_and_error_bars.R#L162-L191
49
85
df <- ToothGrowth
50
86
@@ -107,3 +143,4 @@ good.json[[1]]$error_y <-
107
143
visible = TRUE ,
108
144
type = " data" )
109
145
146
+ }
0 commit comments