如何在R Highcharter中更改气泡图例的范围和颜色?

x759pob2  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(60)

我正在用R中的Highcharter制作一个气泡章程。但是我还没有设法修改气泡大小图例的颜色或图例中显示的气泡大小的范围,即我还没有能够将JavaScript语法here翻译成R。例如,在下面的说明性图表中,将气泡图例的蓝色更改为黑色,并将显示的大小从214、7506.5和14799更改为1000、7000和14000。


下面是上面简单示例图表的代码:

mydata <- tibble(x=sample(seq(1,30,1), 30, replace=T), 
                 y=sample(seq(1,150,1), 30, replace=T),
                 group=sample(seq(1,3,1), 30, replace=T),
                 size=sample(seq(1,15000,1), 30, replace=T))

hchart(mydata, type = "bubble", 
       hcaes(x = x, y = y, size = size, color = group), maxSize = "10%",
       showInLegend = F) %>%
  hc_legend(bubbleLegend = list(enabled = T))

字符串
我真的很感激你的帮助。

c0vxltue

c0vxltue1#

下面您可以在R:https://jsfiddle.net/BlackLabel/x5kLracd/中找到此演示的示例
正如你所看到的,图例在那里工作正常。我希望这个配置会使你的工作更容易!

library(highcharter)

highchart() %>%
  hc_chart(type = "bubble") %>%
  hc_legend(
    enabled = TRUE,
    align = 'left',
    layout = 'vertical',
    verticalAlign = 'top',
    itemMarginTop = 10,
    bubbleLegend = list(
      enabled = TRUE,
      borderWidth = 1,
      connectorDistance = 40,
      maxSize = 70,
      ranges = list(list(), list(), list(color = '#e4d354'))
    )
  ) %>%
  hc_plotOptions(
    series = list(
      maxSize = 70
    )
  ) %>%
  hc_add_series(
    data = list(
      list(x = 95, y = 95, z = 834),
      list(x = 86.5, y = 102.9, z = 1000),
      list(x = 80.8, y = 91.5, z = 242),
      list(x = 80.4, y = 102.5, z = 121)
    )
  ) %>%
  hc_add_series(
    data = list(
      list(x = 80.3, y = 86.1, z = 358),
      list(x = 78.4, y = 70.1, z = 450),
      list(x = 74.2, y = 68.5, z = 598)
    )
  ) %>%
  hc_add_series(
    data = list(
      list(x = 73.5, y = 83.1, z = 678),
      list(x = 71, y = 93.2, z = 314),
      list(x = 69.2, y = 57.6, z = 415),
      list(x = 68.6, y = 20, z = 799)
    )
  ) %>%
  hc_add_series(
    data = list(
      list(x = 65.5, y = 126.4, z = 35.3),
      list(x = 65.4, y = 50.8, z = 28.5),
      list(x = 63.4, y = 51.8, z = 15.4),
      list(x = 64, y = 82.9, z = 31.3)
    )
  )

字符串

相关问题