我使用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
答案 0 :(得分:0)
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