首页 > 解决方案 > 如何正确地使用“符号”R

问题描述

在我希望情节上的标记成为星星的地方使用此代码。

HTMLPlot <- plot_mapbox(dt[dt$KmeansCluster %in% ClusterList[[5]],],
                          x = ~Longitude, y = ~Latitude,size=2) %>%
    add_markers(x = ~ Longitude,
                y = ~ Latitude,
                color = ~ KmeansCluster,
                symbol = "star",
                colors = colourvec2,
                text = ~ paste(KmeansCluster, StopRef),
                hoverinfo = "text") %>%
  layout(mapbox = list(zoom = 12, center = list(lat = ~median(Latitude, na.rm = TRUE), lon = 
  ~median(Longitude, na.rm = TRUE)), style = styles[1]),
         updatemenus = list(list(y = 0.8, buttons = style_buttons)),
         #title = list(text = paste0(opco, " profit by locality"), font = list(family = "Kristen ITC", color = "gold", size = 60)),
         margin = list(l = 50, r = 50, b = 50, t = 100))

代码结果,使用的默认符号是圆圈

使用此代码

    add_markers(x = ~ Longitude,
                y = ~ Latitude,
                color = ~ KmeansCluster,
                symbol = ~ Flag1, symbols = list("circle","star"),
                colors = colourvec2,
                text = ~ paste(KmeansCluster, StopRef),
                hoverinfo = "text")

结果来自代码,其中形成了圆圈和星星,但不是想要的

标签: rr-plotly

解决方案


推荐阅读