R googleVis BubbleChart,设置大小而不设置颜色

Jon*_*gra 6 r googlevis

我试图用R中的gooogleVis制作一个带有两个坐标和一个尺寸参数的气泡图.

当我没有建立颜色变量时,size变量用作颜色而不是大小.我可以包含colorvar但是变量会显示在工具提示中.

我该如何避免这种行为?

我包含了前面提到的两个案例的最小工作示例:

library(googleVis)
set.seed(1)

bubbledata<-data.frame(id=rep("",100),X=sample(10,10,rep=TRUE),
                       Y=sample(10,10,rep=TRUE),Weight=sample(10,10,rep=TRUE))

# This graph uses sizevar as colorvar
bubble <- gvisBubbleChart(bubbledata, idvar="id",
                           xvar="X", yvar="Y",colorvar="",
                           sizevar="Weight")
plot(bubble)

bubbledata$colour<-""

# The output of this one is ok but the tooltip includes the colour var
bubble2 <- gvisBubbleChart(bubbledata, idvar="id",
                          xvar="X", yvar="Y",colorvar="colour",
                          sizevar="Weight")
plot(bubble2)
Run Code Online (Sandbox Code Playgroud)

mto*_*oto 4

如果您只想为气泡图添加一个额外维度,那么我认为将“权重”分配给 sizevar 和 colorvar 是明智的,如下所示:

bubble <- gvisBubbleChart(bubbledata, idvar="id",
                      xvar="X", yvar="Y",
                      sizevar="Weight", colorvar = "Weight")
Run Code Online (Sandbox Code Playgroud)