Stacked area chart are often use to represent time series. These examples are inspired from the cookbook for R. Check the dataviz catalog to better understand what is a stacked area graph! Let’s build some data for the next examples:

#136_stacked_area_graph_1This is the basic stacked area plot proposed by ggplot2.

#136_stacked_area_graph_2You can easily change the color palette:

#136_stacked_area_graph_3To reverse the stacking order, you have to change the order in the initial data frame

#136_stacked_area_graph_4Thus you can give a specific order, still reordering the dataframe as needed:

#136_stacked_area_graph_5You can also draw a proportional stacked area graph: the sum of each year is always equal to hundred and value of each group is represented through percentages. To make it, you have to calculate these percentages first:


Not what you are looking for ? Make a new search !


Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Hammad Ghazanfar Recent comment authors
newest oldest most voted
Notify of
Hammad Ghazanfar
Hammad Ghazanfar

need a commonds to draw a time series with double y axis (left and right both) from excel sheet