Reputation: 3
I am trying to plot some series with errorbars using highcharter and I couldn't find a way to do it efficiently.
Moreover, some of the attributes of the errorbars do not seem to respond while being manipulated from highcharter. (taken from here).
For instance,
df <- data.frame(cbind(c(1,2,3), c(5,6,7)))
hchart(t1, "errorbar",
y = X2,
low = X2 -0.5,
high = X2 + 0.5,
color = 'red',
stemWidth = 1,
whiskerLength = 1) %>%
hc_add_series(data = t1$X2,
color = "red")
When I change the color and whiskerLength arguments of the errorbar series nothing seems to happen in the output.
Please can anyone help me to understand
1) How to plot a series with errorbars efficiently 2) Why some attributes do not seem to work with the API.
Thank you very much for your help!
Upvotes: 0
Views: 1171
Reputation: 3029
2) hchart
has a different behavior when the argument is a data.frame
. In that case the ...
arguments are the aesthetic mappings instead of the usual arguments to the series.
1) So, to have more control in what you want you can use just hc_add_series
:
library(dplyr)
highchart() %>%
hc_add_series(data = list_parse(mutate(df, low = X2 - 0.5, high = X2 + 0.5)),
type = "errorbar", color = "red", stemWidth = 1, whiskerLength = 1) %>%
hc_add_series(data = df$X2, color = "red")
1.2) Other options is set the parameter of the series via hc_plotOptions
:
hchart(df, "errorbar",
y = X2,
low = X2 -0.5,
high = X2 + 0.5) %>%
hc_add_series(data = df$X2, color = "red") %>%
hc_plotOptions(
errorbar = list(
color = "red",
stemWidth = 1,
whiskerLength = 1
)
)
Hope this helps.
Upvotes: 2