我正在尝试绘制一些高程数据(通常在 -90 到 90 度之间),并且使用coord_polar
. 看看这段代码:
library(ggplot2)
#
r = c(2:8)*20
e = c(-4:9)*10
a = c(0:71)*5
points = expand.grid(r,e,a)
colnames(points) = c("distance", "elevation", "azimuth")
points$elevation[points$elevation <0] = points$elevation + 360
forEle = subset(points, azimuth == 0)
#ele_range =
ggplot(forEle, aes( x=elevation, y=distance))+
geom_point()+
coord_polar(theta = "x", start = -1.5708, direction = -1)+
scale_y_continuous(breaks = c(0:16)*10, limits=c(0, 160)) +
scale_x_continuous(breaks=seq(0, 359, by=30), labels=c(expression(0^degree), expression(30^degree), expression(60^degree), expression(90^degree), expression(60^degree), expression(30^degree), expression(0^degree), expression(-30^degree), expression(-60^degree), expression(-90^degree), expression(-60^degree), expression(-30^degree)), limits=c(0, 360)) +
labs(title = "",
x = "x",
y = "y")+
theme(legend.position="bottom")
我的第一个困难是尝试将负角映射到绘图(我通过向所有负值添加 360 度来做到这一点),但我想知道是否有更好的方法来做到这一点。其次,更重要的是,我想将输出剪辑(或限制)从 -90 到 90 度,即图的右侧,但我无法做到。对此问题的任何帮助表示赞赏。