如何更改 R 中 highcharter 中图例的比例?
How can I change the scale of the legend in highcharter in R?
这是来自 highcharter
包网站的一些开源代码,详细说明了如何使用 hcmap
加载地图。
library(highcharter)
# produces the following map inline
hcmap("countries/us/us-all", data = data_fake, value = "value",
joinBy = c("hc-a2", "code"), name = "Fake data",
dataLabels = list(enabled = TRUE, format = '{point.name}'),
borderColor = "#FAFAFA", borderWidth = 0.1,
tooltip = list(valueDecimals = 2, valuePrefix = "$", valueSuffix = " USD"))
我想知道的是whether/how我可以改变右下角图例的比例。如果我想要对数刻度或一些自定义值怎么办?有没有办法用这个包做到这一点?
对于对数刻度,尝试通过管道传输到 hc_colorAxis(type = "logarithmic")
:
library(highcharter)
library(dplyr)
data("USArrests", package = "datasets")
USArrests <- mutate(USArrests, `woe-name` = rownames(USArrests))
set.seed(1)
data_fake <- tibble(test = sample(1:300000, 50, replace = TRUE),
`woe-name` = USArrests$`woe-name`)
hcmap(map = "countries/us/us-all", data = data_fake,
joinBy = "woe-name", value = "test", name = "woe-name",
dataLabels = list(enabled = TRUE, format = '{point.name}'),
borderColor = "#FAFAFA", borderWidth = 0.1,
tooltip = list(valueDecimals = 2, valuePrefix = "$", valueSuffix = " USD")
) %>% hc_colorAxis(type = "logarithmic")
编辑: 自定义色标也是可能的,参见 https://www.highcharts.com/forum/viewtopic.php?t=33569。
这是来自 highcharter
包网站的一些开源代码,详细说明了如何使用 hcmap
加载地图。
library(highcharter)
# produces the following map inline
hcmap("countries/us/us-all", data = data_fake, value = "value",
joinBy = c("hc-a2", "code"), name = "Fake data",
dataLabels = list(enabled = TRUE, format = '{point.name}'),
borderColor = "#FAFAFA", borderWidth = 0.1,
tooltip = list(valueDecimals = 2, valuePrefix = "$", valueSuffix = " USD"))
我想知道的是whether/how我可以改变右下角图例的比例。如果我想要对数刻度或一些自定义值怎么办?有没有办法用这个包做到这一点?
对于对数刻度,尝试通过管道传输到 hc_colorAxis(type = "logarithmic")
:
library(highcharter)
library(dplyr)
data("USArrests", package = "datasets")
USArrests <- mutate(USArrests, `woe-name` = rownames(USArrests))
set.seed(1)
data_fake <- tibble(test = sample(1:300000, 50, replace = TRUE),
`woe-name` = USArrests$`woe-name`)
hcmap(map = "countries/us/us-all", data = data_fake,
joinBy = "woe-name", value = "test", name = "woe-name",
dataLabels = list(enabled = TRUE, format = '{point.name}'),
borderColor = "#FAFAFA", borderWidth = 0.1,
tooltip = list(valueDecimals = 2, valuePrefix = "$", valueSuffix = " USD")
) %>% hc_colorAxis(type = "logarithmic")
编辑: 自定义色标也是可能的,参见 https://www.highcharts.com/forum/viewtopic.php?t=33569。