具有抖动点的Boxplot - 如何使用渐变颜色和非离散数据作为抖动点?

时间:2015-07-12 01:36:19

标签: r colors gradient

快速提问。我使用以下R代码创建了一个箱形图,并重叠了抖动点:

    ##########################Business Risk and FFO/Debt##########################
ratings <- read.csv(file.path("C:/","RawRatingDataPub.csv"), sep=",")
ratings$BusRisk <- factor(ratings$BusinessRisk,
                          levels=c("Excellent","Strong","Satisfactory"))
library(ggplot2)
ggplot(ratings, aes(x=BusRisk, y=FFO_Debt))+ 
  scale_color_discrete(name  ="Rating", 
                       breaks=c("AA-","A+","A","A-","BBB+","BBB","BBB-","BB+","BB","-BB","B+","B","B-","CCC+"),
                       labels=c("AA-","A+","A","A-","BBB+","BBB","BBB-","BB+","BB","-BB","B+","B","B-","CCC+"))+
  scale_shape_discrete(name="Industry")+  
  geom_boxplot(fill="cornflowerblue",
               color="black", notch=FALSE)+
  geom_jitter(aes(colour = Rating, shape = Industry))+
  geom_rug(side="r", color="cornflowerblue")+
  xlab("\nBusiness Risk")+
  ylab("FFO to Debt")+
  theme(legend.position="bottom")
ggsave(file="BRFFO.pdf")

我基本上喜欢输出。我发布了图像......但是我没有足够的积分,所以这个链接应该有效,http://postimg.org/image/8bcovyqwn/

您可以在以下链接https://www.dropbox.com/s/vog1qaczvx9i2cf/RawRatingDataPub.csv?dl=0

找到数据源

但是,我想知道是否有一种方法可以让渐变色方案上的评级为绿色到黄色。

我一直在这,所以任何帮助都会受到赞赏。

-T

0 个答案:

没有答案