@@ -80,17 +80,18 @@ empty <- ggplot() + geom_blank()
80
80
scatter <- ggplot(d ) + geom_point(aes(x = x , y = y ))
81
81
hist_right <- ggplot(d ) + geom_histogram(aes(x = y )) + coord_flip()
82
82
s <- subplot(
83
- hist_top , empty , scatter , hist_right ,
84
- nrows = 2 , widths = c(0.8 , 0.2 ), heights = c(0.2 , 0.8 ),
83
+ hist_top , empty , empty , scatter , empty , hist_right ,
84
+ nrows = 2 , widths = c(0.5 , 0.3 , 0. 2 ), heights = c(0.4 , 0.6 ),
85
85
margin = 0.005 , shareX = TRUE , shareY = TRUE
86
86
)
87
87
88
88
test_that(" Row/column height/width" , {
89
89
l <- expect_traces(s , 3 , " width-height" )
90
- expect_equivalent(diff(l $ layout $ xaxis $ domain ), 0.8 - 0.005 )
91
- expect_equivalent(diff(l $ layout $ xaxis2 $ domain ), 0.2 - 0.005 )
92
- expect_equivalent(diff(l $ layout $ yaxis $ domain ), 0.2 - 0.005 )
93
- expect_equivalent(diff(l $ layout $ yaxis2 $ domain ), 0.8 - 0.005 )
90
+ expect_equivalent(diff(l $ layout $ xaxis $ domain ), 0.5 - 0.005 )
91
+ expect_equivalent(diff(l $ layout $ xaxis2 $ domain ), 0.3 - 0.005 )
92
+ expect_equivalent(diff(l $ layout $ xaxis3 $ domain ), 0.2 - 0.005 )
93
+ expect_equivalent(diff(l $ layout $ yaxis $ domain ), 0.4 - 0.005 )
94
+ expect_equivalent(diff(l $ layout $ yaxis2 $ domain ), 0.6 - 0.005 )
94
95
})
95
96
96
97
test_that(" recursive subplots work" , {
@@ -170,54 +171,3 @@ test_that("geo+cartesian behaves", {
170
171
expect_equivalent(geoDom $ y , c(0 , 0.68 ))
171
172
})
172
173
173
-
174
-
175
- test_that(" May specify legendgroup with through a vector of values" , {
176
-
177
- # example adapted from https://github.com/ropensci/plotly/issues/817
178
- df <- dplyr :: bind_rows(
179
- data.frame (x = rnorm(100 ,2 ), Name = " x1" ),
180
- data.frame (x = rnorm(100 ,6 ), Name = " x2" ),
181
- data.frame (x = rnorm(100 ,4 ), Name = " x3" )
182
- )
183
- df $ y <- rnorm(300 )
184
-
185
- # marker definition...
186
- m <- list (
187
- size = 10 ,
188
- line = list (
189
- width = 1 ,
190
- color = " black"
191
- )
192
- )
193
-
194
- base <- plot_ly(
195
- df ,
196
- marker = m ,
197
- color = ~ factor (Name ),
198
- legendgroup = ~ factor (Name )
199
- )
200
-
201
- s <- subplot(
202
- add_histogram(base , x = ~ x , showlegend = FALSE ),
203
- plotly_empty(),
204
- add_markers(base , x = ~ x , y = ~ y ),
205
- add_histogram(base , y = ~ y , showlegend = FALSE ),
206
- nrows = 2 , heights = c(0.2 , 0.8 ), widths = c(0.8 , 0.2 ),
207
- shareX = TRUE , shareY = TRUE , titleX = FALSE , titleY = FALSE
208
- ) %> % layout(barmode = " stack" )
209
-
210
- # one trace for the empty plot
211
- l <- expect_traces(s , 10 , " subplot-legendgroup" )
212
-
213
- # really this means show three legend items (one is blank)
214
- expect_equivalent(
215
- sum(sapply(l $ data , function (tr ) tr $ showlegend %|| % TRUE )), 4
216
- )
217
-
218
- expect_length(
219
- unlist(lapply(l $ data , " [[" , " legendgroup" )), 9
220
- )
221
-
222
- })
223
-
0 commit comments