【问题标题】:Changing point color on a gvisMap in the googleVis R package更改 googleVis R 包中 gvisMap 上的点颜色
【发布时间】:2014-11-28 00:08:00
【问题描述】:

我在 R 中使用 googleVis 包,特别是我正在尝试使用 gvisMap 命令解决问题。作为一个例子,我将使用here 显示的 Hurriance Andrew 数据:

AndrewMap <- gvisMap(Andrew, "LatLong" , "Tip", 
                     options=list(showTip=TRUE, 
                                  showLine=TRUE, 
                                  enableScrollWheel=TRUE,
                                  mapType='terrain', 
                                  useMapTypeControl=TRUE))
plot(AndrewMap)

我想改变点的颜色。例如,使用 gvisGeoMap 或 gvisGeoChart 我可以根据一些变量将点设置为不同的颜色,但问题是您失去了使用 gvisMap 获得的缩放、居中和滚动。我也有分类数据,而不是连续数据,所以我想使用 gvisMap 根据归因于该点的一些分类变量为这些点着色。

我尝试过使用选项,但这些只是配置选项,而且 gvisMap 本身似乎没有更改点颜色的默认选项。对可以做到这一点的替代方法有什么建议吗?

【问题讨论】:

    标签: r google-maps googlevis gvisgeomap


    【解决方案1】:

    试试 plotGoogleMaps 包。 这对我有用。

    library(plotGoogleMaps); library(sp)
    library(googleVis) # for the data
    data(Andrew)
    coordinates(Andrew) = ~ Long + Lat      
    proj4string(Andrew) = CRS("+proj=longlat +datum=WGS84")
    Andrew2 <- SpatialPointsDataFrame(Andrew, data = data.frame( ID = row.names(Andrew) ) )  
    m <- plotGoogleMaps(Andrew2, filename='myMap1.html')
    

    此外,这也适用于分类变量。

    ic <- iconlabels(attribute = Andrew$Category, colPalette=rainbow(3), icon=TRUE, at=NULL, height=10, scale=0.6)
    m <- plotGoogleMaps(Andrew2, filename='myMap1.html', iconMarker=ic)
    

    我在 plotGoogleMaps 包中发现了更多种类的控件,虽然坐标的处理对于非专家来说比较困难,但还是可以访问的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-05
      • 2013-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-11
      相关资源
      最近更新 更多