[英]ggplot2: missing coordinate value in polar plot
我想做一堆極點圖。 所以這是我使用ggplot2
代碼:
x <- runif(min = -pi, max = pi, n = 100)
y <- runif(n = 100)
df1 <- data.frame(x = x, y = y)
library(ggplot2)
ggplot(df1, aes(y = y, x = x)) +
geom_point() +
ylim(0,1) +
theme_light() +
theme(legend.position="none", panel.border=element_blank(),
axis.title = element_blank(), axis.text.y = element_blank()) +
scale_x_continuous(labels = paste(seq(-180,180,30)),
breaks = seq(-pi,pi, length=13)) +
coord_polar()
我得到以下情節:
但是,正如我們所看到的,缺少180的軸。 我怎么得到這個? (我不想同時顯示y的比例尺,或者如果顯示的話,則希望能夠控制在那里顯示的比例。)
有什么建議么?
您可以在pi處添加垂直線,但使其透明。 如果使用xintercept=c(-pi,pi)
,則將獲得-180/180作為標簽。
ggplot(df1, aes(y = y, x = x)) +
geom_point() +
ylim(0,1) +
theme_light() +
geom_vline(aes(xintercept=pi), col='transparent') +
theme(legend.position="none", panel.border=element_blank(),
axis.title = element_blank(), axis.text.y = element_blank()) +
scale_x_continuous(labels = paste(seq(-180,180,30)),
breaks = seq(-pi,pi, length=13)) +
coord_polar()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.