Remove extra space and ring at the edge of a polar plot

The extra space is generated by the outermost circle of a panel.grid. The grid is added by default in the theme you have used (and in most other ggplot themes; default settings here)

Thus, remove panel.grid in theme. You might then create an own grid, according to taste, using e.g. geom_hline and geom_vline. Here I used the breaks you had specified in scale_x and _y as intercepts. I picked line colour and size from default panel.grid.major in theme_bw.

ggplot(data = df) +
  geom_point(aes(x = bng, y = rng, color = det), size = 5, alpha = 0.7) +
  geom_hline(yintercept = seq(0, 15000, by = 3000), colour = "grey90", size = 0.2) +
  geom_vline(xintercept = seq(0, 360-1, by = 45), colour = "grey90", size = 0.2) +
  coord_polar(theta="x", start = 0, direction = 1) +
  labs(x = '', y = '') +
  scale_color_manual(name="",
                     values = c('red', 'black'),
                     breaks = c(FALSE, TRUE),
                     labels = c('Not Detected', 'Detected')) +
  scale_x_continuous(limits = c(0, 360), expand = c(0, 0), breaks = seq(0, 360-1, by = 45)) +
  scale_y_continuous(limits = c(0, 15000), breaks = seq(0, 15000, by = 3000)) +
  theme_bw() +
  theme(panel.border = element_blank(),
        legend.key = element_blank(),
        axis.ticks = element_blank(),
        axis.text.y = element_blank(),
        panel.grid  = element_blank())

enter image description here

Leave a Comment