如何在一个图中为不同的序数类别着色?

时间:2018-04-03 07:53:45

标签: r

我需要在我的马赛克情节上用不同颜色的颜色不粗鲁,有点粗鲁和非常粗鲁。我是怎么做到的

 > table2p
           rbabyF
    hchildF  Not rude Somewhat rude Very rude
        No  65.225564     24.060150 10.714286
        Yes 82.894737     13.157895  3.947368
    > mosaicplot(table2p,  main="Babies vs parents/nonparents", xlab = "Does the person have children?", ylab = "Is it rude to bring baby aboard")

1 个答案:

答案 0 :(得分:0)

mosaicplot有一个参数color(请参阅documentation)。所以这应该有效:

mosaicplot(table2p,  
       main="Babies vs parents/nonparents", 
       xlab = "Does the person have children?", 
       ylab = "Is it rude to bring baby aboard",
       color = c("blue", "red", "green"))