A simple graphing tool that attempts to generate a standard waterfall chart in generic Python.
The idea was first brought to my attention by Jeremy Howard, who remarked that no such easy to use package existed. The underlying method borrows from Chris Moffitt's stacked bar charts approach, and improves upon data range reliability, appearance, and chart options.
The primary aim of the package is to provide a quick and reliable way to generate waterfall charts on a whim, for both accounting and random forest interpretation purposes.
There is currently one function:
quick_charts()
: Given two sequences ordered appropriately, of contribution amounts and labels, generate a standard waterfall chart
There are three features:
-
sorted_value: Sorts contributions by absolute value in the chart
-
threshold: Groups all contributions under a certain threshold value into an 'other' group
-
formatting: Formats Y axis labels and bar chart labels to the specified input
Additionally, there are several arguments that control for chart title, axis names, bar colors, custom bar labels for
'other' and 'net', and x label rotation angles
Check out the examples.
Simply install the Python waterfallcharts
package:
$ pip install waterfallcharts
or upgrade to the latest version:
$ pip install -U waterfallcharts
As detailed in the example and source code, the function assumes two list inputs, one of the contribution NAMES and the other of the contribution AMOUNTS. Please note that the NET SUM of all contributions is not an input to the function, and is calculated for you.
import waterfall_chart
a = ['sales','returns','credit fees','rebates','late charges','shipping']
b = [10,-30,-7.5,-25,95,-7]
my_plot = waterfall_chart.plot(a, b)
$ python setup.py sdist upload