Skip to content

At some point I needed to generate a gazillion waterfall charts so this is just the barebones code to deal with my spesific use case at the time.

Notifications You must be signed in to change notification settings

Tooblippe/waterfall-chart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

waterfall.py

Build Status


Simple function that implements a waterfall chart in python. I have not been able to find any decent implementation of a waterfall chart online and implementing it in Excel is neither trivial nor pretty.

#usage

This implementation is still very basic as I needed it fairly quickly

An exmaple Excel file is provided here (test.xls) and the demo reads an Excel file into a pandas DataFrame and passes the values and xtick names to the drawing function.

Item Value
Tomatos 50
Potatos 30
Gas 90
Correction -10
Unplanned 9
Stuff 20
Other Stuff 20
Foo 10

Edit the following lines to point to an Excel file with the data. The waterfall() function is called with the parsed Excel file pandas dataframe.

    import pandas
    import waterfall

    df = pandas.ExcelFile('test.xls').parse("Sheet1")
    values = df['Rbn']
    xtick_names = df['Values']
    Waterfall( values, xtick_names, fig_size = ( 11, 6 ), xticks_fontsize = 9, outfile = "temp.png")

or just run demo.py

    import waterfall
    waterfall.demo('test.xls')

waterfall

custom matplotlib

The function makes small modifications to the Matplotlib config file and also sets the default size to someting that should be easy to copy and paste to powerpoint.

Bitdeli Badge

About

At some point I needed to generate a gazillion waterfall charts so this is just the barebones code to deal with my spesific use case at the time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages