The waterfall plots or staircase plots are observed mostly in financial reports. I have not come across a nonfinancial application of these plots. The first and last columns of the plot are usually a total column and the floating columns indicate the incremental change. In this recipe, we generate some fake data of sales figures for every month.
In order to generate a waterfall plot, we will need to install and load the plotrix
package in R.
The data for the same is imported in R using the read.csv()
function. If we view the data, it begins with a total from last year's sales and we have some gains and some losses in sales, which are indicated by positive and negative values. The last row represents the current year's sales, which is the sum of all the rows:
sales = read.csv("waterf.csv")
The waterfall plot is constructed in R using the staircase.plot()
function:
staircase.plot(sales$value, totals= sales$logic, labels = sales$labels...