We have a data frame of the form:

col1 col2 col3 col4 col5 col6 col7 0 Sem 01.2017 aaa 4 Noo RX 1 Kola 01.2017 aaa 4 Foo RX 2 Kety 02.2017 bbb 3 Roo RX 3 Pyti 01.2017 bbb 5 Kaa RX 4 Pyti 02.2017 ccc 1 Joo RX 5 Kola 03.2017 ccc 3 PPP RX 6 Café 01.2017 ccc 1 Cf FX 7 Kety 02.2017 ccc 1 T FX 

You need to display the bars as a percentage (or quantitative - visually the same)

Something like this, but with an individual color legend for each bar Something like this, but with an individual color legend for each bar

The algorithm is like this: we look at all the columns of the data frame, we determine the first bar in which the largest share of a category (for example, 60%), then from the remaining ones we draw a bar, with other categories (1 bar = 1 column with its own categories) - we derive the one where the maximum share of one of the categories is already less than 60%. Parameters: N bars, the minimum size of the fraction in percentage.

    0