我正在尝试用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)
答案 0 :(得分:4)
如果您只想在气泡图中添加一个额外维度,那么我认为将'weight'分配给sizevar和colorvar是明智的,如下所示:
bubble <- gvisBubbleChart(bubbledata, idvar="id",
xvar="X", yvar="Y",
sizevar="Weight", colorvar = "Weight")