去除极坐标图中的矩形边框 [英] Removing Rectangular Border In Polar Plot

查看:96
本文介绍了去除极坐标图中的矩形边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 ggplot2 在 R 中生成了一个极坐标图,并想找到一种方法来从两个方面清理该图.第一个是如何删除圆形图周围的矩形框,该矩形框也有 x/y 标签和 y 刻度线.第二个是如何删除图中最后一个距离环 15000 和具有方位角刻度的环之间的额外空间?我在下面放置了一个自包含示例.感谢您的帮助.

I have generated a polar plot in R using ggplot2 and would like to find a way to clear-up the plot in two aspects. The first is how do I remove the rectangular box around the circular plot that also has the x/y labels and the y tick marks. The second is how do I remove the extra space in the plot between the last range ring at 15000 and the ring that has the azimuth ticks? I have placed a self contained example below. Thank you for any help.

# Load needed Libraries ---------------------------------------------------

library(ggplot2)

# Generate Fake Data ------------------------------------------------------

N    = 25
bng  = runif(N, min =  0, max = 360)
rng  = rlnorm(N, meanlog = 9, sdlog = 1)
det  = runif(N, min = 0, max = 1) >= 0.5

det  = factor(det)

data = data.frame(bng, rng, det)

# Generate the Plot -------------------------------------------------------

plot = ggplot(data) + theme_bw() +
  geom_point(aes(x = bng, y = rng, color = det), size = 5, alpha = 0.7) +
  coord_polar(theta = 'x', start = 0, direction = 1) +
  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)) +
  theme(legend.key = element_blank()) +
  scale_color_manual(name = '', values = c('red', 'black'), breaks = c(FALSE, TRUE), labels = c('Not Detected', 'Detected'))
plot

推荐答案

theme( panel.border = element_blank(), axis.text.y = element_blank(), axis.ticks = element_blank()) 将移除边框,刻度和标签

theme( panel.border = element_blank(), axis.text.y = element_blank(), axis.ticks = element_blank()) will remove the border, ticks and label

  plot = ggplot(data) + theme_bw() +
  geom_point(aes(x = bng, y = rng, color = det), size = 5, alpha = 0.7) + 
  theme( panel.border = element_blank(), axis.text.y = element_blank(), axis.ticks = element_blank())+
  coord_polar(theta = 'x', start = 0, direction = 1) +
  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)) +
  theme(legend.key = element_blank()) +
  scale_color_manual(name = '', values = c('red', 'black'), breaks = c(FALSE, TRUE), labels = c('Not Detected', 'Detected'))
 plot

这篇关于去除极坐标图中的矩形边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆