Description
openedon Oct 27, 2022
In some (undeniably edge, but still real) cases current version of ggplot2 draws polygons near 0 with too few segments. Short example is this:
library(ggplot2)
df <- data.frame(
x = 1:3,
y = c(2, 4, 20)
)
ggplot(df, aes(x, y, fill = factor(y))) +
geom_col(width = 1, show.legend = FALSE) +
scale_y_continuous(limits = c(0, 50)) +
coord_polar() +
theme_void()
Which leads to a plot like this (heavily zoomed in), where you can see red bar only has two outer segments and looks like a diamond, rather than a segment of a circle.
This becomes more obvious, when displaying plots in high real-world resolution - on a big screen, projector, etc., because it doesn't depend on a graphics device.
I've found out (from a stackoverflow post discussing this very same issue) that changing the default value of segment_length
in coord_munch()
from 0.01 to 0.002 improves quality (see image below), and doesn't seem to degrade performance too much (in my not-very-thorough benchmarks it was down 0-4%).
Given that, my proposal is to change the default value of segment_length
to something smaller.