I'd like to create a magic quadrant in highcharter
. In ggplot2
I found a nice example on 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")
How could this be done in highcharter
?
So I tried making a polygon in highcharter from this highcharts example: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/polygon/ Unf not working with this simple example code:
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
You need to check the data in the poloygon example.
In geometry you need at least 3 point to get a polygon, so not sure why you put only 2 points and a NULL
value.
Try with:
library(highcharter)
highchart() %>%
hc_add_series(name='Polygon',type='polygon',data=list(c(1,4),c(2,4), c(3,3)))
And more detailed example:
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())