forked from tidyverse/ggplot2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lines.r
99 lines (68 loc) · 3.33 KB
/
lines.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
vcontext("lines")
dat <- data.frame(x=LETTERS[1:5], y=1:5)
# geom_abline tests
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_abline(intercept = 2, slope = 0, colour = "red")
save_vtest("geom_abline: intercept=2, slope=0")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_abline(intercept = 0, slope = 1, colour = "red")
save_vtest("geom_abline: intercept=0, slope=1 Should have same values as bars")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_abline(intercept = 2, slope = 0, colour = "red") +
coord_flip()
save_vtest("geom_abline, coord_flip: intercept=2, slope=0")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_abline(intercept = 0, slope = 1, colour = "red") +
coord_flip()
save_vtest("geom_abline, coord_flip: intercept=0, slope=1, should have same values as bars")
# geom_hline tests
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_hline(yintercept = 2, colour = "red")
save_vtest("geom_hline: intercept=2")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_hline(yintercept = 2, colour = "red") +
coord_flip()
save_vtest("geom_hline, coord_flip: intercept=2")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_hline(yintercept = 2, colour = "red") +
coord_polar()
save_vtest("geom_hline, coord_polar: intercept=2, should have a circle at r=2")
# geom_vline tests
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_vline(xintercept = 2, colour = "red")
save_vtest("geom_vline: intercept=2")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_vline(xintercept = 2, colour = "red") +
coord_flip()
save_vtest("geom_vline, coord_flip: intercept=2")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") +
geom_vline(xintercept = 2, colour = "red") +
coord_polar()
save_vtest("geom_vline, coord_polar: intercept=2, should have a ray at 2")
# hline, vline, and abline tests with coord_map
library(maps)
library(mapproj)
nz <- data.frame(map("nz", plot=FALSE)[c("x","y")])
nzmap <- qplot(x, y, data=nz, geom="path")
nzmap + geom_hline(yintercept=-45) + coord_map()
save_vtest("geom_hline: intercept=-45, projection=mercator")
nzmap + geom_vline(xintercept=172) + coord_map()
save_vtest("geom_vline: intercept=172, projection=mercator")
nzmap + geom_abline(intercept=130, slope=-1) + coord_map()
save_vtest("geom_abline: intercept=130, slope=-1 projection=mercator")
nzmap + geom_hline(yintercept=-45) + coord_map(project="cylindrical")
save_vtest("geom_hline: intercept=-45, projection=cylindrical")
nzmap + geom_vline(xintercept=172) + coord_map(project="cylindrical")
save_vtest("geom_vline: intercept=172, projection=cylindrical")
nzmap + geom_abline(intercept=130, slope=-1) + coord_map(project="cylindrical")
save_vtest("geom_abline: intercept=130, slope=-1, projection=cylindrical")
nzmap + geom_hline(yintercept=-45) +
coord_map(project='azequalarea', orientation=c(-36.92,174.6,0))
save_vtest("geom_hline: intercept=-45, projection=azequalarea")
nzmap + geom_vline(xintercept=172) +
coord_map(project='azequalarea', orientation=c(-36.92,174.6,0))
save_vtest("geom_vline: intercept=172, projection=azequalara")
nzmap + geom_abline(intercept=130, slope=-1) +
coord_map(project='azequalarea', orientation=c(-36.92,174.6,0))
save_vtest("geom_abline: intercept=130, slope=-1, projection=azequalarea")
end_vcontext()