|
WATERFALL CHARTName:
Given a response variable Y, the first bar is drawn from zero to Y(1), the second bar is drawn from Y(1) to (Y(1) + Y(2)), and so on. You can optionally request that the final value be plotted from zero the final value with the command (this is the default)
To turn this off, use the command
It is sometimes desired to plot all the positive values and then all the negative values. In this case, you can optionally request that after the positive values a bar be drawn from the sum of the positive values to zero. To request this, enter
To turn this off, use the command
The default is ON. Note that if the response variable is not sorted so that all the positive values come before the negative values, then this option will not be implemented. By default, the x-axis value is simply the sequence number. However, you can optionally specify an x-axis variable. For example, you may want to leave a space to add your own bars for intermediate sub-totals. The width of the bars can be specified with the command
The default is 1 with <value> typically in the range 0.5 to 1. The appearance of the plot can be controlled with REGION commands. Specifically,
This is demonstrated in the Program examples below.
where <y> is the response variable; and where the <SUBSET/EXCEPT/FOR qualification> is optional. For this syntax, the x-axis value is simply the sequence number.
where <y> is the response variable; <x> is the horizontal axis variable; and where the <SUBSET/EXCEPT/FOR qualification> is optional.
WATERFALL CHART Y X
SET WATERFALL CHART FINAL VALUE ON SET WATERFALL CHART BAR WIDTH 1
. Step 1: Create the data - this example from Wikipedia
.
read y
420
210
-170
-140
end of data
.
. Step 2: Set plot control
.
case asis
title case asis
label case asis
tic mark label case asis
.
let n = size y
let ntot = n + 2
xlimits 1 ntot
major x1tic mark number ntot
minor x1tic mark number 0
x1tic mark label format alpha
x1tic mark label content Productcr()Revenue Servicescr()Revenue Totalcr()Revenue ...
Fixedcr()Costs Variablecr()Costs Total
tic mark offset units data
x1tic mark offset 0.8 0.8
.
set waterfall chart total positive on
set waterfall chart final value on
set waterfall chart bar width 0.8
.
region fill on on on
region fill color green red blue
line blank all
.
. Step 3: Generate the plot
.
y1label Dollars
title Waterfall Chart (Wikipedia Example)
waterfall chart y
Program 2:
. Step 1: Create the data - this example from Wikipedia
.
read y
217
-55
37
end of data
.
. Step 2: Set plot control
.
case asis
title case asis
label case asis
tic mark label case asis
.
let n = size y
let ntot = n + 1
xlimits 1 ntot
major x1tic mark number ntot
minor x1tic mark number 0
x1tic mark label format alpha
x1tic mark label content Unitssp()incr()Stock Damaged Refurbished Salablecr()Units
tic mark offset units data
x1tic mark offset 0.8 0.8
.
set waterfall chart final value on
set waterfall chart bar width 0.5
.
region fill on on on
region fill color green red cyan
.
. Step 3: Generate the plot
.
y1label Number of Units
title Waterfall Chart for Inventory Audit of Men's Tee-Shirts (Wikipedia Example)
waterfall chart y
.
justification center
let ycum = cumulative sum y
let nlast = ntot - 1
loop for k = 1 1 nlast
let xcoor = k
let aval = y(k)
if aval >= 0
let ycoor = ycum(k)
let ycoor = ycoor + 10
else
let km1 = k - 1
let ycoor = ycum(km1)
let ycoor = ycoor + 10
end of if
move data xcoor ycoor
text ^aval
end of loop
let aval = ycum(nlast)
let ycoor = aval + 10
move data ntot ycoor
text ^aval
Date created: 05/22/2025 |
Last updated: 05/22/2025 Please email comments on this WWW page to [email protected]. | ||||||||||||||||