I am trying to make a bubble chart with two coordinates and a size parameter with gooogleVis in R.
When I don't establish the colour variable, the size variable is used as colour instead of as size. I can include a colorvar but then the variable is displayed in the tooltip.
How can I avoid this behaviour?
I include a minimum working example with the two cases mentioned before:
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)
If you only want one extra dimension to your bubblechart, then I think it is sensible to assign 'weight' to both sizevar and colorvar, like this:
bubble <- gvisBubbleChart(bubbledata, idvar="id",
xvar="X", yvar="Y",
sizevar="Weight", colorvar = "Weight")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With