@@ -131,7 +131,34 @@ test_that("Warn when drawing multiple copies of the same function", {
131
131
expect_warning(f(), " Multiple drawing groups" )
132
132
})
133
133
134
- test_that(" `data` is not used by stat_function()" , {
135
- expect_warning(geom_function(data = mtcars , fun = identity ), " `data` is not used" )
136
- expect_warning(stat_function(data = mtcars , fun = identity ), " `data` is not used" )
134
+ test_that(" Line style can be changed via provided data" , {
135
+ df <- data_frame(fun = " #D55E00" )
136
+
137
+ base <- ggplot(df ) +
138
+ geom_function(aes(color = fun ), fun = identity , n = 6 ) +
139
+ scale_color_identity()
140
+ ret <- layer_data(base )
141
+ expect_identical(ret $ x , seq(0 , 1 , length.out = 6 ))
142
+ expect_identical(ret $ y , ret $ x )
143
+ expect_identical(ret $ colour , rep(" #D55E00" , 6 ))
144
+
145
+ base <- ggplot() +
146
+ geom_function(
147
+ data = df , aes(color = fun ), fun = identity , n = 6
148
+ ) +
149
+ scale_color_identity()
150
+ ret <- layer_data(base )
151
+ expect_identical(ret $ x , seq(0 , 1 , length.out = 6 ))
152
+ expect_identical(ret $ y , ret $ x )
153
+ expect_identical(ret $ colour , rep(" #D55E00" , 6 ))
154
+
155
+ base <- ggplot() +
156
+ stat_function(
157
+ data = df , aes(color = fun ), fun = identity , n = 6
158
+ ) +
159
+ scale_color_identity()
160
+ ret <- layer_data(base )
161
+ expect_identical(ret $ x , seq(0 , 1 , length.out = 6 ))
162
+ expect_identical(ret $ y , ret $ x )
163
+ expect_identical(ret $ colour , rep(" #D55E00" , 6 ))
137
164
})
0 commit comments