forked from plotly/plotly.R
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-ggplot-labels.R
More file actions
37 lines (32 loc) · 1.24 KB
/
test-ggplot-labels.R
File metadata and controls
37 lines (32 loc) · 1.24 KB
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
context("labels")
test_that("ggtitle is translated correctly", {
ggiris <- ggplot(iris) +
geom_point(aes(Petal.Width, Sepal.Width)) +
ggtitle("My amazing plot!")
info <- save_outputs(ggiris, "labels-ggtitle")
expect_identical(info$layout$title, "My amazing plot!")
})
test_that("ylab is translated correctly", {
ggiris <- ggplot(iris) +
geom_point(aes(Petal.Width, Sepal.Width)) +
ylab("sepal width")
info <- save_outputs(ggiris, "labels-ylab")
expect_identical(info$layout$xaxis$title, "Petal.Width")
expect_identical(info$layout$yaxis$title, "sepal width")
})
test_that("scale_x_continuous(name) is translated correctly", {
ggiris <- ggplot(iris) +
geom_point(aes(Petal.Width, Sepal.Width)) +
scale_x_continuous("petal width")
info <- save_outputs(ggiris, "labels-scale_x_continuous_name")
expect_identical(info$layout$xaxis$title, "petal width")
expect_identical(info$layout$yaxis$title, "Sepal.Width")
})
test_that("angled ticks are translated correctly", {
ggiris <- ggplot(iris) +
geom_point(aes(Petal.Width, Sepal.Width)) +
theme(axis.text.x=element_text(angle=45))
info <- save_outputs(ggiris, "labels-angles")
expect_identical(info$layout$xaxis$tickangle, -45)
})
# TODO: test label colors.