我想在 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
完成?
所以我尝试从这个高图示例中在高图中创建一个多边形: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
1 回答
您需要检查poloygon示例中的数据 .
在几何中,你需要至少3个点来获得一个多边形,所以不确定为什么你只放了2个点和
NULL
值 .试试:
更详细的例子: