【发布时间】:2020-07-01 23:49:56
【问题描述】:
我正在尝试使用 Highcharter R 包(基于 Highcharts 库)创建一个 wordcloud,以在一个 wordcloud 中显示两类情绪(正面和负面)。
重点是我也想展示一个传奇。我的问题是,当我要显示图例时,单词并没有对齐。当我必须以正确的方式显示数据时,我无法显示图例。
显示我的问题的最简单情况如下:
library(tidyverse)
library(highcharter)
positive <-
c(
"tranquilo",
"tranquila",
"nova" ,
"burocratico" ,
"bom" ,
"assertivo" ,
"rapido" ,
"transparente"
)
negative <-
c(
"trabalhoso" ,
"conduzida" ,
"passa" ,
"congelada" ,
"pessima" ,
"moroso" ,
"pouco",
"opinar" ,
"passado" ,
"afastado"
)
df <- list(
tibble("term" = positive,
"sentiment" = "positive"),
tibble("term" = negative,
"sentiment" = "negative")
) %>% bind_rows()
df %>%
hchart(
"wordcloud",
hcaes(name = "term", group = "sentiment"),
showInLegend = TRUE,
colorByPoint = FALSE
) %>%
hc_colors(c("#E0362C", "#189D3E"))
结果是:
如果我通过“颜色”hcaes(name = "term", color = "sentiment") 更改“组”参数,那么我得到的是:
提前致谢。 弗拉德米尔。
PS:我认为 JS 中的解决方案也可以帮助我。
【问题讨论】:
标签: javascript r highcharts r-highcharter