@@ -136,3 +136,35 @@ test_that("ggplotly understands ggmatrix", {
136136 L <- save_outputs(GGally :: ggpairs(iris ), " plotly-subplot-ggmatrix" )
137137})
138138
139+ test_that(" geo+cartesian behaves" , {
140+ # specify some map projection/options
141+ g <- list (
142+ scope = ' usa' ,
143+ projection = list (type = ' albers usa' ),
144+ lakecolor = toRGB(' white' )
145+ )
146+ # create a map of population density
147+ density <- state.x77 [, " Population" ] / state.x77 [, " Area" ]
148+ map <- plot_ly(
149+ z = density ,
150+ text = state.name , locations = state.abb ,
151+ type = ' choropleth' , locationmode = ' USA-states' , geo = " geo"
152+ ) %> % layout(geo = g )
153+ # create a bunch of horizontal bar charts
154+ vars <- colnames(state.x77 )
155+ barcharts <- lapply(vars , function (var ) {
156+ plot_ly(x = state.x77 [, var ], y = state.name , type = " bar" ,
157+ orientation = " h" , name = var ) %> %
158+ layout(showlegend = FALSE , hovermode = " y" ,
159+ yaxis = list (showticklabels = FALSE ))
160+ })
161+ s <- subplot(
162+ subplot(barcharts , margin = 0.01 ), map ,
163+ nrows = 2 , heights = c(0.3 , 0.7 )
164+ )
165+ l <- expect_traces(s , 9 , " geo-cartesian" )
166+ geoDom <- l $ layout [[grep(" ^geo" , names(l $ layout ))]]$ domain
167+ expect_equal(geoDom $ x , c(0 , 1 ))
168+ expect_equal(geoDom $ y , c(0 , 0.68 ))
169+ })
170+
0 commit comments