Confidence Bands
data <- jsonlite::fromJSON("https://echarts.apache.org/examples/data/asset/data/confidence-band.json")
data |>
dplyr::mutate(
date = as.Date(date, "%Y-%m-%d"),
l = l + value,
u = u - value
) |>
e_charts(date) |>
e_line(value, symbol = "none") |>
e_band(
l, u,
areaStyle = list(list(color = "grey"), list(color = "grey"))
)
Area Bands
data(EuStockMarkets)
as.data.frame(EuStockMarkets) |> dplyr::slice_head(n=200) |>
dplyr::mutate(day=1:dplyr::n()) |>
e_charts(day) |>
e_line(CAC, symbol='none') |>
e_band2(DAX, FTSE, color='lemonchiffon') |>
e_band2(DAX, SMI, color='lightblue', itemStyle=list(borderWidth=0)) |>
e_y_axis(scale=TRUE) |>
e_datazoom(start = 50)
Correlation Matrix
cor(mtcars) |>
e_charts() |>
e_correlations(order = "hclust") |>
e_tooltip()
Error bars
df <- data.frame(
x = factor(c(1, 2)),
y = c(1, 5),
upper = c(1.1, 5.3),
lower = c(0.8, 4.3)
)
df |>
e_charts(x) |>
e_bar(y) |>
e_error_bar(lower, upper)
Histogram
# data.frame
df <- data.frame(
x = 1:100,
y = rnorm(100, 20, 12)
)
df |>
e_charts() |>
e_histogram(y, name = "histogram") |>
e_tooltip()
Density
Plot the density on a different Y axis as its range differs much from the that of the histogram.
df |>
e_charts() |>
e_histogram(y) |>
e_density(y, name = "density", areaStyle = list(opacity = .4),
smooth = TRUE, y_index = 1) |>
e_tooltip()