1+ context(" abline" )
2+
3+ test_that(" abline" ,{
4+
5+ # # Setup up coordinate system (with x == y aspect ratio):
6+ plot(c(- 2 ,3 ), c(- 1 ,5 ), type = " n" , xlab = " x" , ylab = " y" , asp = 1 )
7+ # # the x- and y-axis, and an integer grid
8+ abline(h = 0 , v = 0 , col = " gray60" )
9+
10+ })
11+
12+ test_that(" abline gsplot" ,{
13+ gs = points(gsplot(), c(- 2 ,3 ), c(- 1 ,5 )) %> %
14+ abline(h = 0 , v = 0 , col = " gray60" )
15+ expect_equal(names(gs $ view ), c(" points" ," abline" ," window" ))
16+ })
17+
18+ test_that(" segments" ,{
19+ x <- stats :: runif(12 ); y <- stats :: rnorm(12 )
20+ i <- order(x , y ); x <- x [i ]; y <- y [i ]
21+ plot(x , y , main = " arrows(.) and segments(.)" )
22+ # # draw arrows from point to point :
23+ s <- seq(length(x )- 1 ) # one shorter than data
24+ arrows(x [s ], y [s ], x [s + 1 ], y [s + 1 ], col = 1 : 3 )
25+ s <- s [- length(s )]
26+ segments(x [s ], y [s ], x [s + 2 ], y [s + 2 ], col = ' pink' )
27+ })
28+
29+ test_that(" segments gsplot" ,{
30+ x <- stats :: runif(12 ); y <- stats :: rnorm(12 )
31+ i <- order(x , y ); x <- x [i ]; y <- y [i ]
32+ gs = points(gsplot(), x , y , main = " arrows(.) and segments(.)" )
33+ # # draw arrows from point to point :
34+ s <- seq(length(x )- 1 ) # one shorter than data
35+ gs = arrows(gs , x [s ], y [s ], x [s + 1 ], y [s + 1 ], col = 1 : 3 )
36+ s <- s [- length(s )]
37+ gs = segments(gs , x [s ], y [s ], x [s + 2 ], y [s + 2 ], col = ' pink' )
38+ expect_equal(names(gs $ view ), c(" points" ," arrows" ," segments" ," window" ))
39+
40+ })
0 commit comments