Ribbon chart in R

I am looking in the R-implementation (maybe an html widjet in a java script) a laid-in histogram in the style of a ribbon, which allows you to see the rating change for each category in dynamics. This is similar to a running bar chart. enter image description here

Search rseek.org returned no results.

+4
source share
1 answer

Firstly: not a fan of this ribbon stylized histogram; while colorful and stylish, it is difficult to synthesize relevant information. But this is just my opinion.

You can create a similar plot in ggplot2with geom_ribbon. The following is a minimal example:

# Sample data
set.seed(2017);
one <- sample(5:15, 10);
two <- rev(one);
df <- cbind.data.frame(
    x = rep(1:10, 2),
    y = c(one, two),
    l = c(one - 1, two - 1),
    h = c(one + 1, two + 1),
    id = rep(c("one", "two"), each = 10));


require(ggplot2);
ggplot(df, aes(x = x, y = y)) +
    geom_ribbon(aes(ymin = l, ymax = h, fill = id), alpha = 0.4) +
    scale_fill_manual(values = c("#E69F00", "#56B4E9"));

enter image description here

If you need interactivity, you can wrap it inside plotly::ggplotly.

+3
source

Source: https://habr.com/ru/post/1693017/


All Articles