forked from tidyverse/ggplot2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminor-breaks.r
41 lines (32 loc) · 1.25 KB
/
minor-breaks.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
vcontext("minor-breaks")
p <- ggplot(NULL, aes(1:3, 1:3)) + geom_point() +
scale_x_continuous(breaks = 1:3, minor_breaks = c(1.25, 2.75)) +
scale_y_continuous(breaks = 1:3, minor_breaks = c(1.25, 2.75))
p
save_vtest("manual minor breaks")
p + coord_polar()
save_vtest("manual minor breaks with coord_polar")
set.seed(342)
df <- data.frame(
date = seq(as.Date("2012-2-29"), length.out = 100, by = "1 day")[sample(100, 50)],
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")
)
p
save_vtest("major breaks: months, minor breaks: weeks")
p + coord_polar()
save_vtest("major breaks: months, minor breaks: weeks, with coord_polar")
ggplot(NULL, aes(letters[1:3], 1:3)) + geom_point()
save_vtest("default breaks")
qplot(1:1e4, 1:1e4) + scale_x_continuous(trans = log2_trans()) + scale_y_log10()
save_vtest("scale_x_continuous(trans = log2_trans()) + scale_y_log10")
qplot(1:5, 1:5) + scale_x_continuous(trans = exp_trans(2)) + scale_y_continuous(trans = exp_trans(2))
save_vtest("scale_x_continuous(trans = exp_trans(2)) + scale_y_continuous(trans = exp_trans(2))")
end_vcontext()