Skip to content

Commit

Permalink
Fix visual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Sep 5, 2012
1 parent 7a7851c commit 713feae
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions visual_test/coord-polar.r
Expand Up @@ -28,7 +28,7 @@ save_vtest("Rays, circular arcs, and spiral arcs")


dat <- data.frame(x=LETTERS[1:6], y=11:16)
ggplot(dat, aes(x=x, y=y)) + geom_bar() + coord_polar()
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") + coord_polar()
save_vtest("rose plot with has equal spacing")

ggplot(dat, aes(x=as.numeric(x), y=y)) + geom_point() + coord_polar()
Expand All @@ -38,10 +38,10 @@ ggplot(dat, aes(x=as.numeric(x), y=y)) + geom_point() + coord_polar() +
xlim(0, 6) + ylim(0,16)
save_vtest("continuous theta with xlim(0, 6) and ylim(0, 16)")

ggplot(dat, aes(x=x, y=y)) + geom_bar() + coord_polar(theta = "y")
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") + coord_polar(theta = "y")
save_vtest("racetrack plot with expand=F is closed and doesn't have center hole")

ggplot(dat, aes(x=x, y=y)) + geom_bar() + coord_polar(theta = "y") +
ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="identity") + coord_polar(theta = "y") +
scale_x_discrete(expand = c(0, 0.6))
save_vtest("racetrack plot with expand=T is closed and has center hole")

Expand Down
2 changes: 1 addition & 1 deletion visual_test/guide-position.r
Expand Up @@ -34,7 +34,7 @@ save_vtest("facet_wrap, legend on top")

# padding
dat <- data.frame(x=LETTERS[1:3], y=1)
p2 <- ggplot(dat, aes(x=x, y=y, fill=x, colour = 1:3)) + geom_bar() +
p2 <- ggplot(dat, aes(x=x, y=y, fill=x, colour = 1:3)) + geom_bar(stat="identity") +
theme(legend.background = element_rect(colour="black")) + guides(color = "colorbar")
p2
save_vtest("padding in legend box")
Expand Down
20 changes: 10 additions & 10 deletions visual_test/lines.r
Expand Up @@ -4,54 +4,54 @@ dat <- data.frame(x=LETTERS[1:5], y=1:5)

# geom_abline tests

ggplot(dat, aes(x=x, y=y)) + geom_bar() +
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() +
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() +
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() +
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() +
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() +
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() +
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() +
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() +
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() +
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")
Expand Down
1 change: 1 addition & 0 deletions visual_test/minor-breaks.r
Expand Up @@ -15,6 +15,7 @@ df <- data.frame(
price = runif(50)
)
df <- df[order(df$date), ]
library(scales)
p <- qplot(date, price, data=df, geom="line") +
scale_x_date(labels = date_format("%m/%d"), breaks = date_breaks("month"), minor_breaks = date_breaks("week"))

Expand Down
1 change: 1 addition & 0 deletions visual_test/themes.r
@@ -1,4 +1,5 @@
vcontext("themes")
library(grid)

p <- qplot(1:3, 1:3)

Expand Down

0 comments on commit 713feae

Please sign in to comment.