在yarrr pirateplot中,我可以在bean内部更改数据点的颜色吗?

时间:2019-06-21 19:33:59

标签: r plot charts

在数据集中,我尝试使用yarrr pirateplot可视化数据,每个豆子内部的数据点颜色显示x以外的另一个变量的分类值。

我似乎能够根据该变量更改数据点的形状,但由于某种原因不能更改颜色。对于这两种方法,我都在pirateplot中添加了一个参数,该参数具有我感兴趣的变量的一侧。如您在this example上所见,形状使数据无法读取。

library(RColorBrewer)
my_colors <- brewer.pal(nlevels(as.factor(data$Litter)), "Set3")
     '#8DD3C7' '#FFFFB3' '#BEBADA' '#FB8072' '#80B1D3' '#FDB462' '#B3DE69' '#FCCDE5' '#D9D9D9' 

pirateplot(formula = Nb_USV ~ Group + Sex, 
           data=data, 
           theme = 1,  
           inf.f.o = 0, 
           bean.f.o = 0, 
           point.o = 1,
           point.cex = 1,
           point.col = my_colors, 
           point.pch = c(1,2,3,4,5,6,7,8,9))

的输出
dput(head(data,10))

structure(list(X = 0:4, Rat = structure(c(2L, 1L, 3L, 4L, 5L), .Label = c("AB1", 
"AB10", "AB2", "AB3", "AB4", "AB5", "AB6", "AB7", "AB8", "AB9", 
"AC1", "AC10", "AC2", "AC3", "AC4", "AC5", "AC6", "AC7", "AC8", 
"AC9", "AE1", "AE10", "AE11", "AE12", "AE2", "AE4", "AE5", "AE6", 
"AE7", "AE8", "AE9", "AF1", "AF10", "AF11", "AF2", "AF3", "AF4", 
"AF5", "AF6", "AF7", "AF8", "AF9", "BB1", "BB2", "BB3", "BB4", 
"BB5", "BB6", "BB7", "BB8", "BB9", "BC1", "BC10", "BC11", "BC12", 
"BC2", "BC3", "BC4", "BC5", "BC6", "BC7", "BC8", "BC9", "BD1", 
"BD2", "BD3", "BD4", "BD5", "BD6", "BD7", "BD8", "BD9", "DB1", 
"DB10", "DB11", "DB12", "DB2", "DB3", "DB4", "DB5", "DB6", "DB7", 
"DB8", "DB9", "FB1", "FB10", "FB11", "FB2", "FB3", "FB4", "FB5", 
"FB6", "FB7", "FB8", "FB9"), class = "factor"), Litter = structure(c(1L, 
1L, 1L, 1L, 1L), .Label = c("AB", "AC", "AE", "AF", "BB", "BC", 
"BD", "DB", "FB"), class = "factor"), Sex = structure(c(1L, 1L, 
2L, 1L, 1L), .Label = c("F", "M"), class = "factor"), Group = structure(c(2L, 
2L, 2L, 2L, 2L), .Label = c("control", "treated"), class = "factor"), 
    Nb_USV = c(96L, 90L, 60L, 104L, 436L), Nb_66 = c(44L, 38L, 
    27L, 31L, 228L), Fq_66 = c(68.76177391, 63.46334974, 65.58789628, 
    63.89220778, 64.75349018), Duration_66 = c(0.022354545, 0.029968421, 
    0.034651852, 0.013909677, 0.024501754), Nb_40 = c(52L, 52L, 
    33L, 73L, 208L), Fq_40 = c(43.50131661, 40.86846561, 37.93915663, 
    39.59465167, 39.77748591), Duration_40 = c(0.072253846, 0.104738462, 
    0.115115152, 0.11019726, 0.07785), Cut = c(54L, 54L, 54L, 
    54L, 54L)), row.names = c(NA, 5L), class = "data.frame")

免责声明:我对使用R非常陌生。

0 个答案:

没有答案