Consider the following example: there is a three-stage truck maintenance pipeline. Initially, when a Truck comes to the maintenance service, it is added to the first stage and its status in the pipeline is set to “New”. When the technicians start working on it, for diagnosis the problem and removing the issue, its status is changed to “in progress”. When the truck is released from maintenance service its status is change to “released”. Note that a track status can convert from “New” to “released”, if the technicians believe there is nothing wrong with the system and it was just a false alarm.
The pipeline manager would like to know that for a set of trucks coming for maintenance how their statuses change over time. This is called for a stacked plot where the number of trucks in different stages are plotted in stack format. Stack plots are fairly easy to create in R and here is how:
Suppose we have the following data frame:
In this data frame, level is the status of the maintenance, date is the date of status update, and data is the number of trucks in that date with that status.
In order to plot the data in stacked format, we use geom_area in ggplot2 and set the position field to stacked.
This would result in the following stacked plot: