0

我刚刚发现了 rChart 和 googleVis,我要感谢开发人员所做的工作。我的问题很简单,我想在我的轴上为 nplot 添加一个变量标签?我还想知道是否可以将 gvisBubbleChart 的 sizevar 和 colorvar 等变量添加到 nplot ?

谢谢你。

library(rCharts)
VehiculeFunction <- function(data, gamme, absciss, ordinate){

  # Aim: Permet de visualiser les données sous la forme de nuages de points 
  #      croisant GMF*Coût,  Ratio K * Ratio Coût ou bien GMF*Ratio en 
  #      choisissant la gamme qu'on désire
  # Input: data.frame avec notamment GAMME, PROJET, PERIMETRE, NITG, GMF.24,
  #        Cout.24 et libele
  # Output: Graphique avec le croisement choisi ainsi que le libellé étiquetté
  #         sur le point qu'on voudra identifier

  if(absciss == "GMF.24"){
    my.data <- data[data$RANG_NITG_PROJET_K %in% c(1, 2, 3),]
  } else if(absciss == "Ratio.K") {
    my.data <- data[data$RANG_NITG_PROJET_C %in% c(1, 2, 3),]
  }
  my.data2 <- my.data[my.data$GAMME == gamme,]
  X <- my.data2[[absciss]] 
  Y <- my.data2[[ordinate]] 
  SIZEVAR <- my.data2$Ratio.K
  df <- data.frame(X,Y,SIZEVAR)

  plot <- nPlot(x = "X", y = "Y", size = "SIZEVAR", data = df, type = "scatterChart")
  plot$xAxis(axisLabel = 'X')
  plot 
}


VehiculeFunction(data.vehicule, gamme = "M1", "GMF.24", "Cout.24")
4

1 回答 1

1

用法:

gvisBubbleChart(data, idvar = "", xvar = "", yvar = "",
                  colorvar = "", sizevar = "",
                  options = list(), chartid)

例如

 ## Set color and size
 bubble2 <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
                      colorvar="Location", sizevar="Profit",
                      options=list(hAxis='{minValue:75, maxValue:125}'))

http://www.inside-r.org/packages/cran/googleVis/docs/gvisBubbleChart

于 2014-06-12T14:20:40.603 回答