@@ -28,9 +28,8 @@ test_that("coord_fixed() is translated to the right height-width ratio", {
28
28
la <- info $ layout
29
29
expect_identical(tr $ type , " scatter" )
30
30
# height-width ratio check
31
- built <- ggplot_build2(p )
32
- x_range <- range(built [[2 ]]$ ranges [[1 ]]$ x.major_source , na.rm = TRUE )
33
- y_range <- range(built [[2 ]]$ ranges [[1 ]]$ y.major_source , na.rm = TRUE )
31
+ x_range <- range(p $ data $ xval , na.rm = TRUE )
32
+ y_range <- range(p $ data $ yval , na.rm = TRUE )
34
33
yx_ratio <- (y_range [2 ] - y_range [1 ]) / (x_range [2 ] - x_range [1 ])
35
34
expect_identical(la $ height / la $ width , yx_ratio * p $ coordinates $ ratio )
36
35
})
@@ -45,8 +44,8 @@ test_that("coord_fixed() is translated to the right height-width ratio", {
45
44
expect_identical(tr $ type , " scatter" )
46
45
# height-width ratio check
47
46
built <- ggplot_build2(p )
48
- x_range <- range(built [[ 2 ]] $ ranges [[ 1 ]] $ x.major_source , na.rm = TRUE )
49
- y_range <- range(built [[ 2 ]] $ ranges [[ 1 ]] $ y.major_source , na.rm = TRUE )
47
+ x_range <- range(p $ data $ xval , na.rm = TRUE )
48
+ y_range <- range(p $ data $ yval , na.rm = TRUE )
50
49
yx_ratio <- (y_range [2 ] - y_range [1 ]) / (x_range [2 ] - x_range [1 ])
51
50
expect_identical(la $ height / la $ width , yx_ratio * p $ coordinates $ ratio )
52
51
})
0 commit comments