gen_widths: Generate widths for geom_tile with unevenly space x-axis

View source: R/Utils.R

gen_widthsR Documentation

Generate widths for geom_tile with unevenly space x-axis

Description

Calculate the widths needed to fill the white space when we have unevenly spaced x-axis value

Usage

gen_widths(x)

Arguments

x

x-axis vector to plot

Value

weights use in geom_tile

Examples

## Not run: 
df <- data.frame(
  x = rep(c(2, 5, 7, 9, 12), 2),
  y = rep(c(1, 2), each = 5),
  z = factor(rep(1:5, each = 2))
)
w = gen_widths(df$x)
ggplot(df, aes(x, y)) +geom_tile(aes(fill = z, width=w), colour = "white")

## End(Not run)

kklot/ktools documentation built on Aug. 13, 2024, 7:08 p.m.