0
我想根据圆角/方向(0-360度)使用极坐标图来表示频率。出于某种原因,我在试图定义剧情中的比例以表示所有3个角度时遇到了问题。目前只有2个显示(“B”和“C”)。任何帮助将不胜感激。在此先感谢,使用角度数据在极坐标图上绘制频率ggplot2
library(ggplot2)
data <- read.table(text = "stat angle freq perc
A 1 720 79
B 223.5017 121 13
C 117.9372 68 7", header=T)
head(data)
str(data)
db<-data
db$stat<-factor(db$stat)
levels(db$stat)
# Plot
bp<-ggplot(db, aes(x = angle, y = perc), fill = factor(stat)) +
geom_bar(stat="identity", colour="grey100", aes(fill = factor(stat),
width = 16)) +
coord_polar(theta="x", start=0) +
theme_minimal() + ylab("Detections (%)") +
scale_x_continuous("", lim=c(0,360), breaks = seq(0, 315, 45),
labels = c("N","NE","E","SE","S","SW","W","NW"))
bp2<-bp + theme(panel.grid.major = element_line(colour = "grey60", size=0.45),
panel.grid.minor = element_line(colour = "grey60", size=0.45))
的问题,我有与设置正确的刻度来表示角度全圆(0-360)并将这些角度标记为方向(例如“N”,“S”,“W”,“E”等)。 – user1626688 2014-10-01 03:00:55
请参阅我上面更正的答案。 – rnso 2014-10-01 04:22:14
我仍然觉得有什么问题。当我尝试其他“角度”(从0/360分散更大)时,我可以使用更大的宽度。奇怪的是,用这个特定角度1我必须调整宽度。 – user1626688 2014-10-01 05:29:09