Calculate the widths needed to fill the white space when we have unevenly spaced x-axis value
Arguments
- x
x-axis vector to plot
Examples
if (FALSE) {
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")
}