簡體   English   中英

刪除極坐標圖中的矩形邊框

[英]Removing Rectangular Border In Polar Plot

我已經使用ggplot2在R中生成了一個極坐標圖,並且希望找到一種方法可以從兩個方面清除該圖。 第一個是如何刪除圓形圖周圍的矩形框,該矩形圖框也具有x / y標簽和y刻度線。 第二個問題是如何刪除最后一個距離為15000的測距環和具有方位角刻度的環之間的繪圖中的多余空間? 我在下面放置了一個自包含的示例。 感謝您的任何幫助。

# 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())將刪除邊框,刻度線和標簽

  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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM