Gartner 高宪章魔力象限

Gartner magic quadrant in highcharter

我想在 highcharter 中创建一个魔力象限。在 ggplot2 我在 https://gist.github.com/grigory93/f370c5eb997fc74b7b7ec83e73d4dffa

上找到了一个很好的例子
data = data.frame(Aster_experience=c(-0.7, 0.3), 
                  R_experience=c(0.9, 0.3), 
                  coverage=c(60,30),
                  product=c("TeradataAsterR", "toaster"))
ggplot(data, aes(Aster_experience, R_experience)) +
  geom_point(aes(size=coverage, color=product)) +
  geom_text(aes(label=product), size=5, nudge_x=0.0, nudge_y=-0.15) +
  geom_hline(yintercept=0) + geom_vline(xintercept=0) +
  theme_tufte() +
  labs(x="Aster Experience", y="R Experience", title="R Packages for Teradata Aster") +
  scale_x_continuous(limits=c(-1,1), breaks=c(-.8,.8), labels=c('less','more')) +
  scale_y_continuous(limits=c(-1,1), breaks=c(-.8,.8), labels=c('less','more')) +
  scale_size(range=c(15,20), breaks=c(30,60), guide=guide_legend(title="Aster Functions\n     Covered",
                                                                 override.aes = list(color=rev(two_colors)))) +
  scale_color_manual(values=two_colors, guide="none") +
  theme(axis.text.y = element_text(angle = 90, hjust = 1),
        axis.ticks = element_blank(),
        axis.text=element_text(size=12),
        axis.title=element_text(size=14,face="bold"),
        plot.title=element_text(size=18, vjust=1),
        legend.position="right")

highcharter 中如何做到这一点?

所以我尝试根据这个 highcharts 示例在 highcharter 中制作多边形: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/polygon/ Unf 不使用这个简单的示例代码:

library(highcharter)

hc <- highchart()
hc <- hc %>% 
  # hc_title(style = list(color = "red")) %>% 
  # hc_subtitle(text = "I want to add a subtitle too with style",
  #             style = list(color = "#B71C1C", fontWeight = "bold")) %>% 
  hc_xAxis(categories = c(1:12)) %>%
  # hc_add_series(name = "Another data", type = "scatter", color = "#1A237E",
  #               dataLabels = list(align = "center", enabled = TRUE),
  #               data = c(1:12)) %>%
  hc_add_series(name='Polygon',type='polygon',data=list(list(list(1,4),list(2,4),NULL))) %>%
  hc_tooltip(crosshairs = TRUE, shared = TRUE)
hc

您需要检查polygon示例中的数据。

在几何学中,您至少需要 3 个点才能获得多边形,因此不确定为什么只放置 2 个点和一个 NULL 值。

试试:

library(highcharter)
highchart() %>% 
    hc_add_series(name='Polygon',type='polygon',data=list(c(1,4),c(2,4), c(3,3))) 

还有更详细的例子:

highchart() %>% 
  hc_add_series(
    name = 'Polygon', type = 'polygon', color = hex_to_rgba("red", 0.1),
    enableMouseTracking = FALSE,
    data = list(c(-1, 0), c(1, 0), c(1, 1), c(0, 1), c(0, -1), c(-1, -1))
    ) %>% 
  hc_add_series(data = list(c(0.5, 0.5), c(-0.5, 0.5)), type = "scatter") %>% 
  hc_xAxis(min = -1, max = 1) %>% 
  hc_yAxis(min = -1, max = 1) %>% 
  hc_add_theme(hc_theme_null())