I am getting a weird error from ggplot2 only when using a very specific combination of plot features. I can't figure out why this is happening!
Consider this data:
point.dat <- tibble(r = c(0.686, 0.835, 1.016, 1.235, 1.503, 1.828, 2.224, 2.706, 3.292, 4.005), theta = 11.2)
area.dat <- tibble(tmin = 5.62, tmax = 16.9, r = c(3, 3.65))
This data is used to make two different geoms:
area.geom <- geom_ribbon(aes(ymin = tmin, ymax = tmax, x = r), data = area.dat)
point.geom <- geom_point(aes(x = r, y = theta), data = point.dat)
When plotting this data like this, a warning is thrown, though the plot still looks as desired:
ggplot() +
area.geom +
point.geom +
lims(x = c(0, NA), y = c(0, 360)) +
coord_polar(theta = "y", start = -pi / 2, direction = -1)
Warning message:
In munched_lines$id + rep(c(0, max(ids, na.rm = TRUE)), each = length(ids)) :
longer object length is not a multiple of shorter object length
It looks like the line of code that the warning refers to is with geom_ribbon(). See it here at line #160. So, I removed this line from the call, and the warning went away:
ggplot() +
#area.geom +
point.geom +
lims(x = c(0, NA), y = c(0, 360)) +
coord_polar(theta = "y", start = -pi / 2, direction = -1)
However, the warning also goes away, no matter which line from the plot call I remove. So, it seems like the warning is only thrown as a result of some faulty communication among these various features. Why is this happening? Can I do something to fix it?
ggplot() +
area.geom +
#point.geom +
lims(x = c(0, NA), y = c(0, 360)) +
coord_polar(theta = "y", start = -pi / 2, direction = -1)
ggplot() +
area.geom +
point.geom +
#lims(x = c(0, NA), y = c(0, 360)) +
coord_polar(theta = "y", start = -pi / 2, direction = -1)
ggplot() +
area.geom +
point.geom +
lims(x = c(0, NA), y = c(0, 360)) #+
#coord_polar(theta = "y", start = -pi / 2, direction = -1)






