ggplot作図の際に軸ラベルの一部を空白にすることで minor break の ようにみせかける.
label_repl2blank(
nskip = 1,
shift = 0,
first = FALSE,
last = FALSE,
inverse = FALSE,
comma = FALSE,
ptime = FALSE,
ftime = "%Y-%m-%d"
)
何個置きに空白文字にするか, Default: 1.
blankで置き換える位置を右にずらす. Default: 0.
1個目の値を空白にする, Default: FALSE. TRUEで強制的に空白にする . inverse = TRUE の時は逆動作となる.
最後の値を空白にする, Default: FALSE. TRUEで強制的に空白にする. inverse = TRUE の時は逆動作となる.
空白と非空白を逆転させる, Default: FALSE
3桁ごとにコンマをつける, Default: FALSE
Parse date-time type vector, Default: FALSE
Format of date-time, Default: '%Y-%m-%d'
A function
See example and also vignette("repl2blank")
library(ggplot2)
library(magrittr)
library(frabento)
data.frame(year = -6000:1979, haba = treering) %>%
ggplot(aes(x = year, y = haba)) +
geom_line(size = 0.2) +
scale_x_continuous(breaks = seq(-6000, 2000, by = 200),
labels = label_repl2blank(nskip = 4))
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` instead.
#> Don't know how to automatically pick scale for object of type <ts>. Defaulting
#> to continuous.
# label with comma
data.frame(year = -6000:1979, haba = treering) %>%
ggplot(aes(x = year, y = haba)) +
geom_line(size = 0.2) +
scale_x_continuous(breaks = seq(-6000, 2000, by = 200),
labels = label_repl2blank(nskip = 4, comma = TRUE))
#> Don't know how to automatically pick scale for object of type <ts>. Defaulting
#> to continuous.