基于R中条件颜色的螺旋(极地)图?

Spiral (Polar) plot based on conditional color in R?

我希望所有负值都是黄色,所有正值都是蓝色。我的代码有问题,因为我可以看到一些正值变成黄色,反之亦然变成蓝色(见图)。图例比例也没有出现在底部。另外,我将如何使零线加粗。这是我的代码示例

A=runif(20,min = -3, max = 3)
myDate=1981:2000
myData=data.frame(myDate,A)

ggplot(myData, aes(myDate, A))+
  geom_bar(stat = "identity", fill=ifelse( A < 0,"yellow","blue"))+
  coord_polar(theta = "x")+
  theme(legend.position = "bottom")+
  theme_bw()

如有任何帮助,我们将不胜感激。

问题与极坐标无关。
对于颜色,您必须将条件格式设置为 aes() 调用才能起作用。对于图例,您必须将对主题的更改放在 theme_bw() 调用后面。否则它会再次被覆盖。 您可以在 0 处画一条线,使线更粗。
希望这可以帮助。

A=runif(20,min = -3, max = 3)
myDate=1981:2000
myData=data.frame(myDate,A)

ggplot(myData, aes(myDate, A))+
  geom_bar(stat = "identity", aes(fill=ifelse( A < 0,"negative","positive")))+
  coord_polar(theta = "x")+
  scale_fill_manual(values = c("yellow", "blue")) +
  geom_hline(yintercept = 0, color = "black")+
  labs(fill = "Legend") +
  theme_bw() +
  theme(legend.position = "bottom")