ggplot作図の際に軸ラベルの一部を空白にすることで minor break の ようにみせかける.

label_repl2blank(
  nskip = 1,
  shift = 0,
  first = FALSE,
  last = FALSE,
  inverse = FALSE,
  comma = FALSE,
  ptime = FALSE,
  ftime = "%Y-%m-%d"
)

Arguments

nskip

何個置きに空白文字にするか, Default: 1.

shift

blankで置き換える位置を右にずらす. Default: 0.

first

1個目の値を空白にする, Default: FALSE. TRUEで強制的に空白にする . inverse = TRUE の時は逆動作となる.

last

最後の値を空白にする, Default: FALSE. TRUEで強制的に空白にする. inverse = TRUE の時は逆動作となる.

inverse

空白と非空白を逆転させる, Default: FALSE

comma

3桁ごとにコンマをつける, Default: FALSE

ptime

Parse date-time type vector, Default: FALSE

ftime

Format of date-time, Default: '%Y-%m-%d'

Value

A function

Details

See example and also vignette("repl2blank")

Examples

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.